$scope.gridOptions = {
data: 'members',
showSelectionCheckbox: true,
multiSelect: true,
enableColumnResize:true,
jqueryUITheme:true,
columnDefs: [
{field:'Member', displayName:'Member'},
{field:'Relationship', displayName:'Relationship'},
{field:'DOB', displayName:'Date Of Birth'},
{field:'SSN', displayName:'SSN'},
{field:'Gender', displayName:'Gender'},
{field:'MemberID', displayName:'ID'}
]
};
$scope.$on('ngGridEventData', function(){
$scope.gridOptions.selectRow(0, true);
});
Spending lot of time on ng-grid because of ;lack' of documentation. One of the primary reason why I quit DOJO and moved to AngualrJS was because of the Documentaion and support. But in ng-grid I am kind of struggling a bit.
And any pointers on how to perform E2E testing on ng-grid like testing for first row selected etc will be appreciated.
I appreciate in advance!
Thanks
Matt'M
I get ngGridEventData firing on every row if I populate the data array 1 entity at a time. I now populate a temp array and then assign it to the data array. ngGridEventData still fires 4 times, twice when the grid is in init and twice after I assign the data array.
In the controller I do something like:
var dataWasLoaded = false;
$scope.members = [];
$scope.$on("ngGridEventData", function (ev, gridId) {
if (dataWasLoaded && $scope.gridOptions.ngGrid.data.length > 0) {
dataWasLoaded = false;
$scope.gridOptions.selectRow(0, true);
}
});
$scope.getEntityList = function () {
dataWasLoaded = false;
var tmp = [];
... get array of entities via ajax and/or push items into tmp, maybe manipulate the items in tmp somehow ... remember, the grid is "watching" scope.members array so if you mess with it the grid may try to refresh.
$scope.members = tmp; <<<-- this is where the grid sees only one change to the data array. There is a "bug" in ngGrid that fires the ngGridEventData twice but does not seem to bother anything.
dataWasLoaded = true;
}