I'm not sure if this is the best way but it works for me.
Instead of watching for ngGridEventData:
setTimeout(function(){
* $scope.gridOptions.selectRow(0, true);*
},0);
The 0 interval is supposed to execute the function in next digest cycle
when grid is fully initialized.
On Wednesday, June 26, 2013 3:02:22 AM UTC+3, Matt Madhavan wrote:
>
> Hello,
> I would like to Select the first row of the ng-grid after all the rows are
> added to the Grif from within the Controller.
>
> The only option I see is to wait on a Grid Event - like *ngGridEventData *to
> occur, and select the row as follows(in the *blue *color)
>
> $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);*
>> });
>>
>>
> Problem is the Event *ngGridEventData *is called once for every row in
> the Grid. Only after the Grid is fully initialized the gridOption is
> initialized with the methods like selectRow etc.
>
>
> 1. Is there any other better event from the ng-grid that is 'emitted'
> only when (and only once) after the Grid is fully initialized?
> 2. Is this the only way (via *gridOptions*) to do any programmatic
> access to the Grid?
> 3. Are there any additional documentation detailing the the ng-grid's
> design, lifecycle and API besides the WIKI page?
>
> 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
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.