Table selection
How to use delete action on selected line with table selection in ant design
@refinedev/antd to delete a record in a table. This component uses Ant Design's and components. When you click the delete button, a pop-up shows up and asks for confirmation. When confirmed, it executes the useDelete method provided by your dataProvider.render method of the actions column. The recordItemId prop is used to specify the id of the record to be deleted.onChange: This is a callback function that is called when the selection changes. It receives the keys of the newly selected rows.onChange callback or in the callbacks of the additional selection options.useTable hook to create a table with sorting, filtering, and pagination features compatible with Ant Design's Table component. You can also use the component to delete a row. You can find more information about these features in the refine documentation (https://refine.dev/docs).DeleteButtonDeleteButtonDeleteButtonDeleteButtonDeleteButtonButtonPopconfirmuseDeleteManyuseDeleteManyselectedRowKeysselectedRowKeysonSelectChangerowSelectionrowSelectionrowSelectionselectionsonSelectimport {
List,
useTable,
DeleteButton,
} from "@refinedev/antd";
import { Table } from "antd";
const PostList: React.FC = () => {
const { tableProps } = useTable<IPost>();
return (
<List>
<Table {...tableProps} rowKey="id">
<Table.Column dataIndex="id" title="ID" />
<Table.Column dataIndex="title" title="Title" width="50%" />
<Table.Column<IPost>
title="Actions"
dataIndex="actions"
key="actions"
render={(_, record) => (
<DeleteButton size="small" recordItemId={record.id} />
)}
width="50%"
/>
</Table>
</List>
);
};
interface IPost {
id: number;
title: string;
}