[英]How to hide the List Toolbar in react-admin?
I'm using react-admin 2.6.2 and trying currently to edit the layout of the List view. 我正在使用react-admin 2.6.2,目前正在尝试编辑列表视图的布局。 At first I wanted to remove action buttons completely, and I found the answer here at Stackoverflow.
最初,我想完全删除操作按钮,然后在Stackoverflow找到了答案。 I thought, that using empty CardActions would be enough, but there's still empty ListToolbar taking space before my
<List>
starts. 我认为,使用空的CardActions就足够了,但是在
<List>
开始之前,仍然有空的ListToolbar占用空间。 The toolbar is created by List automatically, is there any way to for example edit styles of that toolbar so I could hide it or set the height to 0px? 该工具栏是由List自动创建的,是否有任何方法可以编辑该工具栏的样式,例如我可以将其隐藏或将其高度设置为0px?
I guess one option is to create my custom List.js based on this , but it would be best to use the original source files, so they are also updated when there are new updates to react-admin. 我猜一个选择是基于此创建我的自定义List.js,但是最好使用原始源文件,因此当有新的react-admin更新时,它们也会被更新。
JS code: JS代码:
const NoneActions = props => (
<CardActions />
);
class DemoList extends Component {
render() {
return (
<div>
<List
{...props}
actions={<NoneActions />}
>
<Datagrid>
<TextField source="name" />
<ShowButton />
</Datagrid>
</List>
</div>
);
}
}
Here's the toolbar in DOM: 这是DOM中的工具栏:
<div class="MuiToolbar-root-519 MuiToolbar-regular-521 MuiToolbar-gutters-520 ListToolbar-toolbar-293">
尝试: <List actions={null} {...props}>
列表消失之前的空白区域。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.