Search code examples
reactjsreact-admin

I want to see the detail of the purchase React Admin


I have a shopping list but I want to see the detail in the same list. With what element can I make the touch of the arrow to show me the detail.

List

<List {...props} >
        <Datagrid rowClick="edit" expand={<ItemsProductos />}>
            <TextField source="id" />   
            <TextField source="numero" label="Numero Comprobante" />
            <DateField source="fecha" />
        </Datagrid>
 </List>

Solution

  • React-admin will pass the current record to the component used as expand prop, so you can write your <ItemProductos> component as follows:

    const ItemProductos == ({ record }) => (
        <span>{record.fecha}</span>
    );
    

    This is documented in the react-admin documentation:

    https://marmelab.com/react-admin/List.html#expand