material-table icon indicating copy to clipboard operation
material-table copied to clipboard

Reactjs: How to make all row checkbox check true when material table is loaded?

Open priyankdeeps78 opened this issue 6 years ago • 5 comments

I am using react material table in my project and i want to make select all by default checked. How to achieve that??

function BasicSelection() {
  return (
    <MaterialTable
      title="Basic Selection Preview"
      columns={[
        { title: 'Name', field: 'name' },
        { title: 'Surname', field: 'surname' },
        { title: 'Birth Year', field: 'birthYear', type: 'numeric' },
        {
          title: 'Birth Place',
          field: 'birthCity',
          lookup: { 34: 'İstanbul', 63: 'Şanlıurfa' },
        },
      ]}
      data={[
        { name: 'a', surname: 'b', birthYear: c, birthCity: d },
        { name: 'e', surname: 'f', birthYear: g, birthCity: h },
      ]}        
      options={{
        selection: true
      }}
    />
  )
}

priyankdeeps78 avatar Oct 27 '20 15:10 priyankdeeps78

You can add the following in each object of your data tableData: { checked: true}

dlopezd avatar Nov 06 '20 01:11 dlopezd

@dlopezd Hi! Where can i find all the props available por tableData? Do yo know if i can add data to row behind the scenes without "comitting" the line, something like "isEditing: true" ?

fofederico avatar Dec 02 '20 11:12 fofederico

Hi @fofederico here is the doc: https://material-table.com/#/docs/all-props I haven't work yet editing data with material-table. I could not help you 😞

dlopezd avatar Dec 03 '20 13:12 dlopezd

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.

stale[bot] avatar Mar 03 '21 14:03 stale[bot]

.

priyankdeeps78 avatar Apr 26 '26 14:04 priyankdeeps78