Get data from selected rows in slickgrid

I have a slickgrid in which some rows are hidden by a filter (DataView).

When I now call the grid's getSelectedRows method, I get the indices of the apparently selected rows. But I need the actual data of the selected rows.

+6
source share
5 answers

You should do something like this:

var selectedData = [], selectedIndexes; selectedIndexes = _grid.getSelectedRows(); jQuery.each(selectedIndexes, function (index, value) { selectedData.push(_grid.getData()[value]); }); 

The currently selected Data variable contains data for the selected rows.

+19
source

You have a mistake. It should be "getDataItem", not "getData".

 var selectedData = [],enter code here`selectedIndexes; selectedIndexes = _grid.getSelectedRows(); jQuery.each(selectedIndexes, function (index, value) { selectedData.push(_grid.getDataItem(value)); }); 
+3
source

You can also use this line in a .each loop to pull data from a dataView instead of using getData () from a grid object, as this seems inconsistent depending on the fork:

 var selectedData = [], selectedIndexes; selectedIndexes = _grid.getSelectedRows(); jQuery.each(selectedIndexes, function (index, value) { selectedData.push(_dataView.getItemById(value)); }); 
+1
source
 hObjMarcado = ( grid.getSelectedRows()); for( var a_id in hObjMarcado ) { vres.push( dataview.getItem( hObjMarcado[a_id] )); //la opcion getItem obtiene el elemento especifico, //aun con filtro. } return vres; 
+1
source

If you access the grid from another control. press the button

 var selectRow = gridInstance.getSelectedRows(); alert(gridInstance.getDataItem(selectRow).columnName) 
0
source

Source: https://habr.com/ru/post/900366/


All Articles