Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I get Angular ui-grid selected items

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?

like image 543
Mlalahoi Avatar asked Oct 04 '14 00:10

Mlalahoi


People also ask

What is onRegisterApi in UI grid?

onRegisterApi is used to handle events. For example: If an edit is made, or a row is selected, you would use the onRegisterApi to catch the event and run some function. As for ordering, it doesn't matter if your gridOptions are created first, or the html DOM element.

Is Angular UI grid free?

Generic UI Data Grid is one of the best free grid library. Performance is the main focus point, grid is able to present huge sets of data up to 1 000 000 rows. It greatly integrates with the best javascript framework there is Angular. All of that makes this library a great free to use Angular data table component.

What is NG grid in Angular?

ng-grid is Angular's native implementation of the Grid. There are many plugins from third-parties that can be integrated into AngularUI Pages, but ng-grid exists inside the AngularJs framework and is very rich in functionality and compatibility. Let us create a sample ng-grid and understand how ng-grid works.


2 Answers

Is this what your are looking for ? http://ui-grid.info/docs/#/tutorial/210_selection

  1. Activate grid selection capabilities with the ui-grid-selection tag (and ui.grid.selection module registration in your app
  2. register gridApi and use gridApi.selection to access getSelectedRows()
like image 83
Sycomor Avatar answered Oct 15 '22 11:10

Sycomor


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).

like image 31
Rajush Avatar answered Oct 15 '22 10:10

Rajush