Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 489
HkFreaKuser1673718 Avatar asked Jun 29 '15 11:06

HkFreaKuser1673718


1 Answers

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.

like image 139
HkFreaKuser1673718 Avatar answered Oct 13 '22 20:10

HkFreaKuser1673718