How to programmatically select a row in Ui.grid angularJs?
Asked Answered
P

1

13

I have an issue let me put it simple in my plunker example I want to know why is my $scope.revertSelection() function not working. http://plnkr.co/edit/3KXrUuCsSACuhefmyzxN?p=info

Steps:

  1. Sort right hand grid by Name(descending order)

  2. Select 3-4 rows randomly

  3. Click 'Copy' button all selected rows are copied into $scope.retainSelection

  4. Sort right hand grid by Name(Ascending order)

  5. Click 'Revert' button (this is not working)

I am expecting all the rows previously selected in step 2) to be selected back which is not happening :-( please help me with the issue. I googled but could not find any docs of gridApi.selection to look for other methods to fulfill my requirement.

Note: I am using Ui.grid not ng-grid

Proctoscope answered 29/6, 2015 at 11:38 Comment(1)
Hello, did you get this to work?Polyp
P
19

I should use...

$scope.gridApi.grid.modifyRows($scope.gridOptions.data);
$scope.gridApi.selection.selectRow($scope.gridOptions.data[i]);

...instead of...

$scope.gridApi.selection.selectRow(i);

My friend gave link to docs.

Proctoscope answered 29/6, 2015 at 12:19 Comment(2)
You'll need to call 'modifyRows' first before 'selectRow' $scope.gridApi.grid.modifyRows($scope.gridOptions.data); https://github.com/angular-ui/ui-grid/issues/2267Stanley
I am able to selectRow without modifyRows in 4.0.6Own

© 2022 - 2024 — McMap. All rights reserved.