在 material-ui DataGrid 中,通过checkboxSelection
属性添加复选框选择并通过以下方式收听选择更改非常容易onSelectionChange
:
<DataGrid
columns={columns}
rows={rows}
pageSize={10}
checkboxSelection
onSelectionChange={e => console.log(e.rows)} />
Run Code Online (Sandbox Code Playgroud)
但是有没有办法用一组选中的项目初始化复选框选择?