我有作为父母和孩子的数据。子对象通过parentId
(在子对象中)和id
((在父对象中)关联到父对象
class BasicTreeData extends React.Component {
render() {
return (
<MaterialTable
title="Basic Tree Data Preview"
data={[
{
id: 1,
name: 'a',
surname: 'Baran',
},
{
id: 2,
name: 'b',
surname: 'Baran',
parentId: 1,
},
{
id: 3,
name: 'c',
surname: 'Baran',
parentId: 1,
},
{
id: 4,
name: 'd',
surname: 'Baran',
parentId: 3,
},
{
id: 5,
name: 'e',
surname: 'Baran',
},
{
id: 6,
name: 'f',
surname: 'Baran',
parentId: 5,
},
]}
columns={[
{ title: 'Adı', field: 'name' },
{ title: 'Soyadı', field: 'surname' },
{ title: 'Doğum Yılı', field: 'birthYear', type: 'numeric' },
{
title: 'Doğum Yeri',
field: 'birthCity',
lookup: { 34: 'İstanbul', 63: 'Şanlıurfa' },
},
]}
parentChildData={(row, rows) => rows.find(a => a.id === row.parentId)}
options={{
selection: true,
}}
/>
)
}
}
谁能告诉我,如何通过单击按钮使面板全部展开或全部折叠?