Comments (8)
Use $scope.$digest() after you push
On Dec 19, 2012 4:44 PM, "eu81273" [email protected] wrote:
When clicked an item in First grid then that item is moved into Second
grid.
When I use ng-grid v1.4.0, the routine below works fine.
But now 1.4.1, ng-grid cannot recognize the data changes immediately.Did I wrong something?
//assgined user list
$scope.assignedUsers = [];//all user list
$scope.registeredUsers = [];$scope.assignedUserGridOptions =
{
data: 'assignedUsers',
columnDefs:
[
{
field: 'userId',
displayName: 'id'
},
{
field: 'userName',
displayName: 'name'
},
{
field: 'enabled',
displayName: 'available'
}
],
rowTemplate: '
',
footerVisible: false,
multiSelect: false,
showColumnMenu: false,
canSelectRows: false,
displaySelectionCheckbox: false,
showFilter: true
};$scope.registeredUserGridOptions =
{
data: 'registeredUsers',
columnDefs:
[
{
field: 'userId',
displayName: 'id'
},
{
field: 'userName',
displayName: 'name'
},
{
field: 'enabled',
displayName: 'available'
}
],
rowTemplate: '
',
footerVisible: false,
multiSelect: false,
showColumnMenu: false,
canSelectRows: false,
displaySelectionCheckbox: false,
showFilter: true
};//remove clicked item from "assigned" user list and add the item to "all"
user list
$scope.remove = function(userId)
{
for(var i in $scope.assignedUsers)
{
if($scope.assignedUsers[i].userId == userId)
{
$scope.registeredUsers.push($scope.assignedUsers.splice(i, 1)[0]);
break;
}
}//If skip cords below, ng-grid cannot recognize data changed.
$scope.assignedUsers = JSON.parse(JSON.stringify( $scope.assignedUsers ));
$scope.registeredUsers = JSON.parse(JSON.stringify( $scope.registeredUsers ));};
//remove clicked item from "all" user list and add the item to "assigned"
user list
$scope.insert = function(userId)
{
for(var i in $scope.registeredUsers)
{
if($scope.registeredUsers[i].userId == userId)
{
$scope.assignedUsers.push($scope.registeredUsers.splice(i, 1)[0]);
break;
}
}//If skip cords below, ng-grid cannot recognize data changed.
$scope.assignedUsers = JSON.parse(JSON.stringify( $scope.assignedUsers ));
$scope.registeredUsers = JSON.parse(JSON.stringify( $scope.registeredUsers ));};
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/59.
from ui-grid.
I tried use $scope.$digest() after push but an error occurs like below.
Error: $apply already in progress
at Error ()
at g (http://localhost:8080/common/angularJs/libs/angularjs/js/angular.min.js:82:382)
at Object.e.$digest (http://localhost:8080/common/angularJs/libs/angularjs/js/angular.min.js:84:130)
at Object.$scope.remove (http://localhost:8080/common/angularJs/resources/js/roleAuthorityListController.js:287:10)
at http://localhost:8080/common/angularJs/libs/angularjs/js/angular.min.js:70:328
at http://localhost:8080/common/angularJs/libs/angularjs/js/angular.min.js:139:402
at Object.e.$eval (http://localhost:8080/common/angularJs/libs/angularjs/js/angular.min.js:86:220)
at Object.e.$apply (http://localhost:8080/common/angularJs/libs/angularjs/js/angular.min.js:86:327)
at HTMLDivElement. (http://localhost:8080/common/angularJs/libs/angularjs/js/angular.min.js:139:384)
at HTMLDivElement.f.event.dispatch (http://localhost:8080/common/angularJs/libs/jquery/js/jquery-1.7.1.min.js:3:4351)
from ui-grid.
We may need to rethink the data watching.... In angular if we call apply()
when the rendered rows change we take a huge performance hit. If we call
digest(), it seems that the rows do not get updated in all cases...
On Wednesday, December 19, 2012, Steve wrote:
I tried use $scope.$digest() after push but an error occurs like below.
Error: $apply already in progress
at Error ()
at g (
http://localhost:8080/common/angularJs/libs/angularjs/js/angular.min.js:82:382
)
at Object.e.$digest (
http://localhost:8080/common/angularJs/libs/angularjs/js/angular.min.js:84:130
)
at Object.$scope.remove (
http://localhost:8080/common/angularJs/resources/js/roleAuthorityListController.js:287:10
)
at
http://localhost:8080/common/angularJs/libs/angularjs/js/angular.min.js:70:328
at
http://localhost:8080/common/angularJs/libs/angularjs/js/angular.min.js:139:402
at Object.e.$eval (
http://localhost:8080/common/angularJs/libs/angularjs/js/angular.min.js:86:220
)
at Object.e.$apply (
http://localhost:8080/common/angularJs/libs/angularjs/js/angular.min.js:86:327
)
at HTMLDivElement. (
http://localhost:8080/common/angularJs/libs/angularjs/js/angular.min.js:139:384
)
at HTMLDivElement.f.event.dispatch (
http://localhost:8080/common/angularJs/libs/jquery/js/jquery-1.7.1.min.js:3:4351)—
Reply to this email directly or view it on GitHubhttps://github.com//issues/59#issuecomment-11556466.
-Tim Sweet
from ui-grid.
I think I know why it was automatic before.
we added a flag to prevent the grid from re-rendering when selecting an object:
if (grid.skipDataWatch) {
grid.skipDataWatch = false;
return;
}
when you select the object in the grid we are no longer not firing the watch function, which it was before (which was unintended).
we set it when marking data as selected we set that flag to true.
from ui-grid.
we modified the way we watch the data. We now watch the length of the array instead, so push-pop-splice is the preferred method of adding or removing data to the array now.
from ui-grid.
It seems there's a problem when i splice the data array but don't change the length (i only replace an object by another): ng-grid doesn't update display. For the moment i make a full copy of the old array, splice the new value and reassign the new array to my true data object. It works but it's not very nice...
from ui-grid.
@xelab that's a limitation with the current stable version of angular, and how the grid works. ng-grid only does a "shallow" watch on the data reference, which means it updates the grid if the data length changes or the reference itself changes. It does not update if deeper-level values change. Doing a "deep" watch is possible, but it comes with an extreme performance hit.
In 3.0 and newer versions of angular it will be possible to update in the manner you're wanting.
from ui-grid.
You could locate the
var watcher = _.find(
if (watcher) { watcher.last = -1; }
from ui-grid.
Related Issues (20)
- The checkboxes of the filter of 'Name' pane of the context menu of the table are not receiving keyboard focus. HOT 1
- The Sorting information (Sorted ascending/sorted descending) of the table present under '01NLD Land' is not announced NVDA HOT 1
- [Screen Reader - MCIO DCX-O1NLD]: The Sorting information (Sorted ascending/sorted descending) of the table present under '01NLD Land' is not announced NVDA. HOT 1
- [Supporting the platform-MCIO DCX-O1NLD Land]: In High contrast (Aquatic, Desert, Dusk, Night sky) themes, focus indicator is not visible on the table header and rows. HOT 1
- [Accessibility]: Role defined for "Azure Sign in" is document. HOT 1
- [Accessibility]: On 200% zoom, some elements in the screen are not visible\truncated. HOT 1
- [Accessibility]: NVDA is reading the table as list. HOT 1
- [BUG] Grid width/height broken when grid is in an inactive ui-bootstrap tab HOT 1
- [BUG] Grid objects for Custom filters on the columns are getting lost or overwritten HOT 1
- Grouping does not work when a column has cell template property HOT 2
- [BUG] Aggregate functions are not working with columns which have the cell template property HOT 2
- Event is not triggering for the last character in filter box. HOT 2
- [BUG] Grids display broken for http://ui-grid.info/docs/... HOT 2
- [BUG] [a11y] With NVDA, space bar does not select row in ui-grid HOT 3
- [BUG] Currency symbols are not disturbed while using csvExport method from uiGridExporterService HOT 1
- [FEATURE] Add documentation for Vue3 save-state HOT 3
- [FEATURE] UI-Grid should be able to export the aggregate footer row to an excel file HOT 2
- Formatting is not applied to header column if we export to excel with mobile number HOT 3
- [BUG] scrollToIfNecessary down not working as expected HOT 2
- [BUG] Mousewheel scrolling (vertically) on pinned columns does not work HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ui-grid.