Trung
Trung

Reputation: 1032

react-admin: How to show Delete button on each row in Datagrid

I would like to have Datagrid with Delete button as below (picture is copied from stackoverflow.com):

Datagrid with Delete button

I read react-admin documents but did not find any hints to add a Delete button onto the row. Any body know how to?

Thanks,

Upvotes: 3

Views: 3487

Answers (1)

Mads Lie Jensen
Mads Lie Jensen

Reputation: 390

It is as simple as importing and adding the to your listview:

import { Datagrid, TextField, EditButton, DeleteButton } from 'react-admin';
export const SaleList = props => (
    <List {...props}>
        <Datagrid>
            <TextField source="id"/>
            <EditButton/>
            <DeleteButton/>
        </Datagrid>
    </List>
);

Upvotes: 8

Related Questions