ag-grid row checkbox select. Making checkbox selection equivalent to row-selection

Dexter

(What I'm trying to do: you know how you CTRL or SHIFT to select multiple rows? Why not just make it a click toggle without keyboard keys needed?)

I'm trying to make it so that rowSelected event or rowClicked event should always check the checkbox on the left column for the whole row.

And add onto it, so click on another row, adds it on. Click on another row, checks that and selects that row as well.

Click on an already-selected already-checked row... and it should "uncheck" and "deselect".

So... Row select multiple + checkbox multiple, are equivalent.

              "rowSelection": "multiple",
              "onRowSelected": rowSelected,
              "suppressRowClickSelection": false,


function rowSelected(event){
    console.log("t1 " + event.node.isSelected());
    if(event.node.isSelected()){
        event.node.setSelected(false);
    } else {
        event.node.setSelected(true);
    }
}

Plunker EXAMPLE:

https://embed.plnkr.co/vf0aV6Q0MgA4ZvtzWhFb/

(Plunker example, you cannot uncheck a row anymore)

Dexter

Solved. Basically overriding their default "selection model".

function RowClickEventHandler(event){
    if(event.node.isSelected()){
      console.log("deselected");
      event.node.setSelected(false, false);
    } else {
      event.node.setSelected(true);
      console.log("selected, add");
    }

}

var gridOptions = {
    columnDefs: columnDefs,
    onRowClicked: RowClickEventHandler,
    suppressRowClickSelection: true,
    suppressCellSelection: true,
    rowSelection: 'multiple',
    rowData: null
};

https://plnkr.co/edit/KHj1lstv9GQncxlX4Gvx?p=preview

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

GWT CellTable with checkbox selection and on row click event

SWT Table Viewer add checkbox on row selection

How to add row selection checkbox in data table?

ag-grid: Get double clicked row data within a multiple selection

how to select Table View row selection with custom checkbox button?

disable checkbox selection in Ag-grid

AG Grid - Suppress row selection inside a particular column/cell

persist row checkbox selection in grid with pagination

AG-GRID unable to add icon button into each row of the ag-grid and multiselection checkbox in my ag-grid

Can bootstrap-vue table row selection be selected via a checkbox

Make ag-grid row selectable without a checkbox

Get row item on checkbox Selection in React Material-UI DataGrid

single selection checkbox issue

ng-grid Event for Selection checkbox on header

ng-grid with "select all" checkbox without showing a checkbox for each row

Shift row selection in ag-grid in Internet Explorer selects additional text

Custom ListView checkbox selection

JQuery DataTable select row with checkbox

Retrieve row data on checkbox selection in Ag-grid

group selection & checkbox in ag-Grid

ag-grid header checkbox selection event

Multiple row selection on checkbox and single selection on clicking the row in ag-grid

Parent to child checkbox selection

Ag-Grid enable checkbox selection for a single rowNode

Tabulator - Change style of checkbox within the row selection column

Jquery Datatable Checkbox Selection with Row Click Redirect

Multiple row selection on checkbox and single selection on clicking the row in MUI DataGrid

Change row color based on checkbox with limited selection

how to insert multiple row data based on checkbox selection in Laravel