import React from "react"; import { List, Datagrid, TextField, EditButton,BooleanField } from 'react-admin'; import { useRecordContext } from "react-admin"; const PostPanel = () => { const record = useRecordContext(); return ( <div dangerouslySetInnerHTML={{ __html: record.name }} /> ); }; const postRowStyle = (record, index) => ({ backgroundColor: record.id >= 2 ? '#efe' : 'white', }); export const DatagridAnyList = () => ( <List resource="t_geyao_person"> <Datagrid expand={<PostPanel />} optimized isRowSelectable={ record => record.id > 2 } isRowExpandable={row => row.id} rowStyle={postRowStyle} rowClick="edit" > <TextField source="id" /> <TextField source='name'></TextField> <TextField source='sex'></TextField> <TextField source='salary'></TextField> <BooleanField source='status'></BooleanField> <EditButton /> </Datagrid> </List> );
运行结果 页面重定向