Material-table: Implement default selected rows

Created on 24 Apr 2020  路  3Comments  路  Source: mbrn/material-table

Is your feature request related to a problem? Please describe.
I am unable to provide a default list of items to be selected.

Describe the solution you'd like
A prop that you can pass in an array of objects/indexes of rows to be initially selected.

Describe alternatives you've considered
I override the checked attribute in selectionProps and i use state to determine what's checked and I update that state with onSelectionChange. But after the first selection change, the rest of the selected rows disappear, because they are not part of the state array anymore.

wontfix

Most helpful comment

Add tableData: {checked: true} to your data row before loading ...
sample https://codesandbox.io/s/material-table-selection-sample-wu0s1

All 3 comments

I would like to have the same option on my tables, is possible to achieve it or not?. I'm investigating but I cannot find useful information.

Add tableData: {checked: true} to your data row before loading ...
sample https://codesandbox.io/s/material-table-selection-sample-wu0s1

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You can reopen it if it required.

Was this page helpful?
0 / 5 - 0 ratings