[英]Reactjs: How to make all row checkbox checked true when material table is loaded and deselect when clicked and vice versa?
[英]Reactjs: How to make all row checkbox check true when material table is loaded?
我在我的項目中使用反應材料表,我想默認選中選擇。 如何實現?
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
}}
/>
)
}
您可以在選擇道具中指定選中狀態。
options={{
selection: true,
selectionProps: rowData => ({
checked: true,
})
}}
在這里,它始終檢查行。 您可以更新 function 以具有基於選擇更改事件的條件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.