Where can I get Angular ui-grid selected items
Solution 1
Is this what your are looking for ? http://ui-grid.info/docs/#/tutorial/210_selection
- Activate grid selection capabilities with the ui-grid-selection tag (and ui.grid.selection module registration in your app
- register gridApi and use gridApi.selection to access getSelectedRows()
Solution 2
In addition to the steps above https://stackoverflow.com/a/26188783/2658127, you might have to invoke it through a ng-click event to get the actual value/object. At least that's how I had it working.
Eg:
$scope.selectRow = function(){
$scope.gridApi.selection.getSelectedRows();
};
And call selectRow() from the template.
This is for anybody who have been confused like I did, considering the fact that ui-grid does not have the best documentation (specially for this select portion).
Solution 3
The easiest approach is:
-
Register the gridApi by adding this your controller:
$scope.gridOptions.onRegisterApi = function(gridApi) { $scope.myGridApi = gridApi; };
-
Access the array of selected items:
$scope.myGridApi.selection.getSelectedRows();
![Mlalahoi](https://i.stack.imgur.com/SxIQh.jpg?s=256&g=1)
Mlalahoi
Updated on June 05, 2020Comments
-
Mlalahoi about 4 years
Testing out Angular ui-grid (ng-grid v.3.0). Can not for the life of me find the selected row. I just want to grab the rows or even row ID of row when a user clicks it. Found the top comment here but I think this is outdated: Getting select rows from ng-grid?
Does anyone know where the
gridOptions.selectedItems
is being stored in 3.0? -
Mlalahoi about 9 yearsThanks Rajush, I appreciate the extra info!