【发布时间】:2017-07-24 20:37:44
【问题描述】:
Datagrid 组件包装了 material-ui 的 Table 组件,根据 admin-on-rest 文档,您可以通过 headerOptions、rowOptions、bodyOptions 和 options 属性传递 material-ui 表选项(例如显示复选框的选项) .根据 material-ui 文档,选项是 showCheckboxes 和可选择的。我还发现在网上提到了其他一些内容,例如 displayRowCheckboxes。
正如您在下面的代码中看到的,我已经疯狂地尝试了所有方法。没有任何效果。
<List {...props} sort={{ field: "id", order: "ASC" }}>
<Datagrid
headerOptions={{displaySelectAll: true}}
rowOptions={{selectable: true}}
bodyOptions={{showCheckboxes: true, displayRowCheckBox: true}}
options={{showCheckboxes: true, onRowSelection: ()=>{}}}>
<TextField label="FIRST NAME" source="first_name" />
<TextField label="LAST NANE" source="last_name" />
<EditButton />
</Datagrid>
</List>;
这给了我一个不可选中的标题复选框,但没有行复选框:
【问题讨论】: