ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

Get selected row only through templates?

Open specialjyo opened this issue 13 years ago • 6 comments

I modified my rowTemplate to tell me when a row is selected, is there another way to get the selected row object without the use of a template?

specialjyo avatar May 09 '13 17:05 specialjyo

gridOptions.selectedItems contains the selected rows. Is that what you need?

c0bra avatar May 09 '13 18:05 c0bra

I was hoping you might say that. I'm not using checkboxes, just selecting the row, and $scope.gridOptions never contains a selectedItems array. Do i need to set that up as an empty array when I init the grid so that once I've selected a row, it will populate it? I'll look for examples of selectedItems being used.

specialjyo avatar May 09 '13 18:05 specialjyo

Yea you can do:

$scope.mySelections = [];
$scope.gridOptions = {
    // ...
    selectedItems: $scope.mySelections
}

c0bra avatar May 09 '13 19:05 c0bra

Now its working, thanks for that!

specialjyo avatar May 10 '13 14:05 specialjyo

nicely explained here.. http://coding-issues.blogspot.in/2013/09/getting-selected-rows-from-ng-grid.html

ranadheerrannu avatar Sep 10 '13 12:09 ranadheerrannu

This is working for initial selection. When i change the data of the grid (through some API call) and try to do a new row selection, then previous selected items are retained and the new selections are appended to the previous list. Setting the value of the selectedItems to [] is not working.

http://plnkr.co/edit/CncDWCktXTuBQdDVfuVv

Once the value is set after the initial load, it is not changing.

sureshvsvb avatar Jan 16 '15 19:01 sureshvsvb