I want to perform additional operations on the returned elements from the API before showing them to the user. For example I have an enum field that is 0 or 1 and I would like to show some string instead of the raw value.
const List = (props: any) => (
<List {...props}>
<Datagrid rowClick="edit">
<TextField source="name" />
<TextField source="type" />
<TextField source="value" />
</Datagrid>
</List>
);
The type column is a 0 or a 1 and I would like to show a string to the user.
How can I map the data fetched by the <List> component before it gets passed to my <DataGrid>?
if you have choices like this:
const TYPE_CHOICES = [
{id: 0, name: 'One'},
{id: 1, name: 'Two'},
];
use a SelectField to show the type:
<SelectField source="type" choices={TYPE_CHOICES} />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With