import React from 'react' import { List,TopToolbar,Count,useStore ,SortButton,DatagridConfigurable,SelectColumnsButton, Datagrid, TextField, EditButton, DeleteButton, BooleanField } from 'react-admin' import { MenuList, MenuItem, ListItemText } from '@mui/material'; const PostListActions = () => ( <TopToolbar> <SelectColumnsButton preferenceKey="postList1" /> </TopToolbar> ); const RSortButtonList = () => { const [statusFilter, setStatusFilter] = useStore("statusMenu", { status: 'open' }); return <List actions={<PostListActions />} resource="t_geyao_person" exporter={false}> <SelectColumnsButton preferenceKey="postList1" /> <MenuItem onClick={() => setStatusFilter({ status: true })} > <ListItemText>Pending</ListItemText> <Count resource="t_geyao_person" filter={{ status: true }} /> </MenuItem> <DatagridConfigurable preferenceKey="postList1" // data={data} // total={total} // isLoading={isLoading} // sort={sort} bulkActionButtons={false} > <TextField source="id" /> <TextField source="name" /> <TextField source="sex" /> <TextField source="salary" /> </DatagridConfigurable> </List> } export default RSortButtonList
运行结果