3

I use ag-grid on own aplication. I use option checkboxSelection: true.When i click on checkbox event selectionChanged do not consist form data of row.How to get this data?

code

<ag-grid-common #agGridComponent 
    [gridName]="gridName" 
    [rowData]="supersessionParts" 
    [columnDefinitions]="columnDefs"
    [nodeChildDetails]="getNodeChildDetails" 
    (selectionChanged)="selectionChanged($event)">
</ag-grid-common>

code for set checkbox

{
      headerName: 'Cart',
      lexid: 4456,
      colId: 'selectColumnAdvanced',
      field: 'group',
      checkboxSelection: true,
      suppressResize: true,
      suppressMovable: true,
      suppressSorting: true,
      minWidth: 30,
      width: 35,
      headerComponentFramework: <{new(): CartHeaderComponent}>CartHeaderComponent
}
1
  • 1
    Please add more information. You could provide some code so we can help you better. Please read stackoverflow.com/help/how-to-ask Commented Jun 12, 2019 at 12:27

1 Answer 1

2

The (selectionChanged) callback has the parameter of type SelectionChangedEvent which contains the grid api. From the api, you can get the selected row(s). So your selectionChanged should look like:

onSelectionChanged(event: SelectionChangedEvent) {
    console.log(event.api.getSelectedRows());
}

This is way to go as specified in the ag-grid documentation (see here).

Sign up to request clarification or add additional context in comments.

3 Comments

How to get that particular row data?
@aswininayak you can use the rowClicked event. Take a look at this Stackblitz.
No good at all. Row data should be available as a property on SelectionChangedEvent, as there are circumstances where you'll need to get the clicked row data while doing something with the selected rows.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.