Table component
- State management is done via
useTable
React hook.
- Table rendering is done using
Table
component.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 | import { translate } from '@waldur/i18n';
import Table from '@waldur/table/Table';
import { createFetcher } from '@waldur/table/api';
import { useTable } from '@waldur/table/useTable';
export const RolesList = () => {
const tableProps = useTable({
table: `RolesList`,
fetchData: createFetcher('roles'),
});
return (
<Table
{...tableProps}
columns={[
{
title: translate('Name'),
render: ({ row }) => row.name,
},
{
title: translate('Description'),
render: ({ row }) => row.description,
},
{
title: translate('Assigned users count'),
render: ({ row }) => row.users_count,
},
]}
/>
);
};
|
Column definition consists of two mandatory fields: title
and render
.
In order to be able to make column optional, please specify hasOptionalColumns
property for table and ensure that key
property is defined for columns.