0

I'm working with react TSX, I have a Datagrid on which checkbox selection is enabled. I want to disable selection for certain rows. I came to know that isRowSelectable prop is used in the material UI data grid for that purpose.

Reference : https://material-ui.com/components/data-grid/selection/#disable-selection-on-certain-rows

https://codesandbox.io/s/dxgt5?file=/demo.js

But when I use this in my code below

<DataGrid autoPageSize pagination
    rows={Records}
    columns={columns}
    isRowSelectable = {(params:any) =>params.Records.Status = "success"}
    checkboxSelection />

It gives me the below error

Property 'isRowSelectable' does not exist on type 'IntrinsicAttributes & Pick<GridComponentProps

Detailed error:

Type '{ autoPageSize: true; pagination: true; rows: never[]; columns: GridColDef[]; isRowSelectable: (params: any) => boolean; checkboxSelection: true; onSelectionModelChange: (e: GridSelectionModelChangeParams) => void; }' is not assignable to type 'IntrinsicAttributes & Pick<GridComponentProps, "autoHeight" | "rowHeight" | "headerHeight" | "scrollbarSize" | "columnBuffer" | ... 52 more ... | "getRowId"> & { ...; } & RefAttributes<...>'. Property 'isRowSelectable' does not exist on type 'IntrinsicAttributes & Pick<GridComponentProps, "autoHeight" | "rowHeight" | "headerHeight" |

I searched for a solution but couldn't find one. Can someone please help me with that?

Maryam
  • 357
  • 1
  • 5
  • 16

1 Answers1

0

May be you are using old version of data grid. This feature has been rollout in last week. Please update your data grid package

First uninstall data grid using below command

npm uninstall @material-ui/data-grid

then install it using below command

npm install @material-ui/data-grid

Reference: https://github.com/mui-org/material-ui-x/pull/1659

Babir
  • 29
  • 3
  • I tried this but still getting error but now a different one. Type '(params: any) => string' is not assignable to type '(params: GridRowParams) => boolean'. Type 'string' is not assignable to type 'boolean'. The expected type comes from property 'isRowSelectable' which is declared here on type 'IntrinsicAttributes & Omit & { ...; } & RefAttributes<...>' – Maryam May 24 '21 at 14:17
  • you should return boolean from function which you are using for isRowSelectable props value – Babir May 24 '21 at 15:29