get data of selected rows in slickgrid

前端 未结 5 409
渐次进展
渐次进展 2021-01-05 08:04

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

When I now call the getSelectedRows method of the grid I get the indices of the visibly sele

相关标签:
5条回答
  • 2021-01-05 08:21

    You have a mistake. It needs to be "getDataItem" and not "getData".

    var selectedData = [],enter code here`selectedIndexes;
    
    selectedIndexes = _grid.getSelectedRows();
    jQuery.each(selectedIndexes, function (index, value) {
        selectedData.push(_grid.getDataItem(value));
    });
    
    0 讨论(0)
  • 2021-01-05 08:23

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

    var selectedData = [],
        selectedIndexes;
    
    selectedIndexes = _grid.getSelectedRows();
    jQuery.each(selectedIndexes, function (index, value) {
        selectedData.push(_dataView.getItemById(value));
    });
    
    0 讨论(0)
  • 2021-01-05 08:28

    You must do something like this:

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

    Right now the selectedData variable contains data for selected rows.

    0 讨论(0)
  • 2021-01-05 08:28

    If you access grid from other control like . click button

    var selectRow = gridInstance.getSelectedRows();
    alert(gridInstance.getDataItem(selectRow).columnName)
    
    0 讨论(0)
  • 2021-01-05 08:33
    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;
    
    0 讨论(0)
提交回复
热议问题