Reputation: 123
SlickGrid:
Is there a 'selected'/'isSelected' or similar property for grid rows?
If I use 'grid.getSelectedRows' then the rows seem to be returned in the order they were selected (clicked), not necessarily in the order they appear on the grid. I want the selected rows in visible order, top to bottom.
I can get each item with grid.getDataItem but how do I determine whether the row is selected? Do I need the properties for the row rather than the data item?
for (var i = 0, ii = grid.getDataLength(); i < ii; i++) {
var item = grid.getDataItem(i);
if (!item.selected()) { <- fails because there is no selected property
continue;
}...
Thanks!
Upvotes: 1
Views: 705
Reputation: 2215
I believe this answer would be what you're looking for, according to the docs found here. Max Brodin is correct in suggesting grid.getSelectedRows().
EDIT: To accommodate @AnotherFineMess's request to have it sorted top-bottom in the grid, the code should be:
var items = grid.getSelectedRows().sort(function(a,b){return a - b});
Upvotes: 1