Search code examples
javascriptslickgrid

Get single row using checkbox in SlickGrid?


I have a table with checkbox for each row and i want to get only current(last) selected row using Slickgrid and Javascript.

I am aware of getSelectedRows function of Slickgrid, that returns an array of row indices corresponding to the currently selected rows.But can't find a method to return only last selected row.


Solution

  • If you want to select only current selected row, you could handle the

    onSelectedRowsChanged event

    and do something like:

    var selectedRows = grid.getSelectedRows();
    if( selectedRows.length > 1 ) {
      grid.setSelectedRows( [ selectedRows[ selectedRows.length - 1 ] ] );
    }  
    

    Already answered from Chris Hogan!

    "Disable" multi select in the grid options

    jsfiddle working Test