我在我的项目中使用反应物料表,并且我想默认选中选择。如何实现?
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: 'Mehmet', surname: 'Baran', birthYear: 1987, birthCity: 63 },
{ name: 'Zerya Betül', surname: 'Baran', birthYear: 2017, birthCity: 34 },
]}
options={{
selection: true
}}
/>
)
}
答案 0 :(得分:0)
您可以使用它。
options={{
selection: true,
selectionProps: rowData => ({
disabled: rowData.name === 'Mehmet',
color: 'primary',
checked: rowData.id === '1'
})
}}