mbrn/material-table

How update table styling after sorting?

gabrielizalo opened this issue · 1 comments

I created a Zebra Table with sort columns:

CleanShot 2023-07-26 at 11 21 12@2x

The did setup the zebra style in this way:


<MaterialTable
  data={data}
  columns={columns}
  ...
  options={{
    ...
    rowStyle: (rowData) => ({
      backgroundColor:
        rowData.tableData.id % 2 === 0
          ? "var(--white)"
          : "var(--wild-sand)",
    }),
  }}
/>

After sorting, the background colors remains in the original rows, so the table is not a zebra table anymore:

CleanShot 2023-07-26 at 11 24 17@2x

How I can update the "zebra styling" of the table after sorting?

Thanks

The solution was very easy as pointed here: material-table-core/core#781 (comment)