You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import { BulkSelect } from '@patternfly/react-component-groups';
18
-
import DataViewToolbar from '@patternfly/react-data-view/dist/dynamic/DataViewToolbar';
18
+
import { DataViewToolbar } from '@patternfly/react-data-view/dist/dynamic/DataViewToolbar';
19
+
import { DataViewTable } from '@patternfly/react-data-view/dist/dynamic/DataViewTable';
19
20
20
21
## Data view toolbar
21
22
@@ -29,3 +30,29 @@ Data view toolbar can contain a `pagination`, `bulkSelect` or any other children
29
30
30
31
```
31
32
33
+
## Data view table
34
+
35
+
The **data view table** component renders your columns and rows definition into a [table](/components/table) component.
36
+
37
+
### Basic example
38
+
39
+
```js file="./DataViewTableExample.tsx"
40
+
41
+
```
42
+
43
+
The `DataViewTable` component accepts the following props:
44
+
45
+
-`columns` defining the column headers of the table. Each item in the array can be a `ReactNode` (for simple headers) or an object with the following properties:
46
+
-`cell` (`ReactNode`) content to display in the column header.
47
+
- optional `props` (`ThProps`) to pass to the `<Th>` component, such as `width`, `sort`, and other table header cell properties.
48
+
49
+
-`rows` defining the rows to be displayed in the table. Each item in the array can be either an array of `DataViewTd` (for simple rows) or an object with the following properties:
50
+
-`row` (`DataViewTd[]`) defining the content for each cell in the row.
51
+
- optional `id` (`string`) for the row.
52
+
- optional `props` (`TrProps`) to pass to the `<Tr>` component, such as `isHoverable`, `isRowSelected`, and other table row properties.
53
+
54
+
- optional `ouiaId`
55
+
56
+
- optional `props` (`TableProps`) that are passed down to the `<Table>` component, except for `onSelect`, which is managed internally.
import { DataView } from '@patternfly/react-data-view/dist/dynamic/DataView';
19
19
import { BulkSelect, BulkSelectValue } from '@patternfly/react-component-groups/dist/dynamic/BulkSelect';
20
20
import { DataViewToolbar } from '@patternfly/react-data-view/dist/dynamic/DataViewToolbar';
21
+
import { DataViewTable } from '@patternfly/react-data-view/dist/dynamic/DataViewTable';
21
22
import { BrowserRouter, useSearchParams } from 'react-router-dom';
22
23
23
24
This is a list of functionality you can use to manage data displayed in the **data view**.
@@ -34,9 +35,9 @@ The `useDataViewPagination` hook manages the pagination state of the data view.
34
35
35
36
**Initial values:**
36
37
-`perPage` initial value
37
-
-(optional)`page` initial value
38
-
-(optional)`searchParams` object
39
-
-(optional) `seSearchParams` function
38
+
- optional `page` initial value
39
+
- optional `searchParams` object
40
+
- optional`setSearchParams` function
40
41
41
42
While the hook works seamlessly with React Router library, you do not need to use it to take advantage of URL persistence. The `searchParams` and `setSearchParams` props can be managed using native browser APIs (`URLSearchParams` and `window.history.pushState`) or any other routing library of your choice. If you don't pass these two props, the pagination state will be stored internally without the URL usage.
42
43
@@ -68,8 +69,8 @@ Data view toolbar can display a bulk selection component using the `bulkSelect`
68
69
The `useDataViewSelection` hook manages the selection state of the data view.
69
70
70
71
**Initial values:**
71
-
-(optional)`initialSelected` array of record's identifiers selected by default
72
-
-(optional) `matchOption` function to check if given record is selected
72
+
- optional `initialSelected` array of record's identifiers selected by default
73
+
-`matchOption` function to check if given record is selected
73
74
74
75
*When no `matchOption` is passed, the `Array.prototype.includes()` operation is performed on the `selected` array.*
0 commit comments