HkFreaKuser1673718
HkFreaKuser1673718

Reputation: 757

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

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

Upvotes: 13

Views: 28977

Answers (1)

HkFreaKuser1673718
HkFreaKuser1673718

Reputation: 757

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.

Upvotes: 19

Related Questions