@patternfly/react-table 4.30.19 → 4.31.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/dist/umd/react-table.css +10037 -9923
- package/dist/umd/react-table.min.css +9755 -9641
- package/package.json +6 -6
- package/src/components/Table/examples/Table.md +181 -71
- package/src/components/TableComposable/examples/ComposableTable.md +209 -52
- package/src/demos/Table.md +552 -159
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-table",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.31.3",
|
|
4
4
|
"description": "This library provides a set of React table components for use with the PatternFly 4",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"clean": "rimraf dist"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@patternfly/react-core": "^4.
|
|
35
|
-
"@patternfly/react-icons": "^4.12.
|
|
36
|
-
"@patternfly/react-styles": "^4.12.
|
|
37
|
-
"@patternfly/react-tokens": "^4.13.
|
|
34
|
+
"@patternfly/react-core": "^4.161.2",
|
|
35
|
+
"@patternfly/react-icons": "^4.12.3",
|
|
36
|
+
"@patternfly/react-styles": "^4.12.3",
|
|
37
|
+
"@patternfly/react-tokens": "^4.13.4",
|
|
38
38
|
"lodash": "^4.17.19",
|
|
39
39
|
"tslib": "^2.0.0"
|
|
40
40
|
},
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"react": "^16.8.0 || ^17.0.0",
|
|
47
47
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "9b078ade31862aabeb78d88c9373298215105ac0"
|
|
50
50
|
}
|
|
@@ -2,25 +2,19 @@
|
|
|
2
2
|
id: Table
|
|
3
3
|
cssPrefix: pf-c-table
|
|
4
4
|
section: components
|
|
5
|
-
propComponents:
|
|
6
|
-
[
|
|
7
|
-
'Table',
|
|
8
|
-
'TableHeader',
|
|
9
|
-
'TableBody'
|
|
10
|
-
]
|
|
5
|
+
propComponents: ['Table', 'TableHeader', 'TableBody']
|
|
11
6
|
ouia: true
|
|
12
7
|
---
|
|
13
8
|
|
|
14
9
|
# Table
|
|
15
10
|
|
|
16
|
-
|
|
17
11
|
Note: Table lives in its own package at [@patternfly/react-table](https://www.npmjs.com/package/@patternfly/react-table)!
|
|
18
12
|
|
|
19
13
|
PatternFly has two implementations of a React table.
|
|
20
14
|
|
|
21
15
|
The first is the newer `TableComposable` component. It takes a more explicit and declarative approach, and its implementation more closely mirrors that of an html table. Generally, updates and new feature requests are implemented in the `ComposableTable`.
|
|
22
16
|
|
|
23
|
-
The second is the original `Table` component. It is configuration based and takes a less declarative and more implicit approach about laying out the table structure, such as the rows and cells within it.
|
|
17
|
+
The second is the original `Table` component. It is configuration based and takes a less declarative and more implicit approach about laying out the table structure, such as the rows and cells within it.
|
|
24
18
|
|
|
25
19
|
**For most common use cases, we recommend using `TableComposable`. Both implementations are supported and fully maintained.**
|
|
26
20
|
|
|
@@ -31,8 +25,7 @@ import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon';
|
|
|
31
25
|
import LeafIcon from '@patternfly/react-icons/dist/esm/icons/leaf-icon';
|
|
32
26
|
import FolderIcon from '@patternfly/react-icons/dist/esm/icons/folder-icon';
|
|
33
27
|
import FolderOpenIcon from '@patternfly/react-icons/dist/esm/icons/folder-open-icon';
|
|
34
|
-
|
|
35
|
-
import { Checkbox, ToggleGroup, ToggleGroupItem } from '@patternfly/react-core';
|
|
28
|
+
import SortAmountDownIcon from '@patternfly/react-icons/dist/esm/icons/sort-amount-down-icon';
|
|
36
29
|
|
|
37
30
|
import { css } from '@patternfly/react-styles';
|
|
38
31
|
import styles from '@patternfly/react-styles/css/components/Table/table';
|
|
@@ -41,7 +34,6 @@ import DemoSortableTable from './DemoSortableTable';
|
|
|
41
34
|
|
|
42
35
|
### Table Columns
|
|
43
36
|
|
|
44
|
-
|
|
45
37
|
Array items for columns provided to the `Table`'s `cells` prop, can be simple strings or objects.
|
|
46
38
|
|
|
47
39
|
```
|
|
@@ -69,8 +61,8 @@ interface ICell {
|
|
|
69
61
|
}
|
|
70
62
|
```
|
|
71
63
|
|
|
72
|
-
If you wish to enable other built in features, use `transforms` to apply them to
|
|
73
|
-
column headers or `cellTransforms` to apply them to every cell in that column.
|
|
64
|
+
If you wish to enable other built in features, use `transforms` to apply them to
|
|
65
|
+
column headers or `cellTransforms` to apply them to every cell in that column.
|
|
74
66
|
|
|
75
67
|
```
|
|
76
68
|
// simple
|
|
@@ -95,11 +87,11 @@ columns: [
|
|
|
95
87
|
}
|
|
96
88
|
]
|
|
97
89
|
```
|
|
90
|
+
|
|
98
91
|
Many of the subsequent examples demonstrate how to apply different transformations to enable `Table` features.
|
|
99
92
|
|
|
100
93
|
### Table Rows
|
|
101
94
|
|
|
102
|
-
|
|
103
95
|
Array items for rows provided to the `Table`'s `rows` prop, can be simple strings or objects.
|
|
104
96
|
|
|
105
97
|
```
|
|
@@ -199,10 +191,13 @@ class SimpleTable extends React.Component {
|
|
|
199
191
|
|
|
200
192
|
Custom row wrappers are passed to the `Table` component via the `rowWrapper` prop.
|
|
201
193
|
Each `rowWrapper` should return a tr element.
|
|
194
|
+
|
|
202
195
|
```
|
|
203
196
|
rowWrapper?: (props: RowWrapperProps) => JSX.Element;
|
|
204
197
|
```
|
|
198
|
+
|
|
205
199
|
RowWrapperProps:
|
|
200
|
+
|
|
206
201
|
```
|
|
207
202
|
interface RowWrapperProps {
|
|
208
203
|
trRef?: React.Ref<any> | Function;
|
|
@@ -249,11 +244,7 @@ class RowWrapperTable extends React.Component {
|
|
|
249
244
|
<tr
|
|
250
245
|
{...props}
|
|
251
246
|
ref={trRef}
|
|
252
|
-
className={css(
|
|
253
|
-
className,
|
|
254
|
-
isOddRow ? 'odd-row-class' : 'even-row-class',
|
|
255
|
-
'custom-static-class'
|
|
256
|
-
)}
|
|
247
|
+
className={css(className, isOddRow ? 'odd-row-class' : 'even-row-class', 'custom-static-class')}
|
|
257
248
|
style={isOddRow ? customStyle : {}}
|
|
258
249
|
/>
|
|
259
250
|
);
|
|
@@ -281,14 +272,17 @@ class RowWrapperTable extends React.Component {
|
|
|
281
272
|
### Sortable & wrapping column headers
|
|
282
273
|
|
|
283
274
|
To implement sortable columns:
|
|
275
|
+
|
|
284
276
|
1. Import and apply the `sortable` transform to the desired column.
|
|
285
277
|
2. Pass a managed `sortBy` prop to the `Table` component.
|
|
286
|
-
|
|
278
|
+
`` `sortBy` - Specifies the initial sorting pattern for the table - asc/desc and the index of the column to sort by ``
|
|
287
279
|
3. Pass an `onSort` callback to the `Table` component
|
|
288
|
-
|
|
280
|
+
`` `onSort` - (event: React.MouseEvent, columnIndex: number, sortByDirection: SortByDirection, extraData: IExtraColumnData) => void; ``
|
|
289
281
|
|
|
290
282
|
Note: If you want to add a tooltip/popover to a sortable header, in the `transforms` array the `info` transform has to precede the `sortable` transform.
|
|
291
283
|
|
|
284
|
+
The built in display for sorting is not fully responsive, as the column headers will be displayed per row when the screen size is small. The example below showcases how sorting may have a custom control display that can be used for small screen sizes.
|
|
285
|
+
|
|
292
286
|
```js
|
|
293
287
|
import React from 'react';
|
|
294
288
|
import {
|
|
@@ -365,6 +359,151 @@ class SortableTable extends React.Component {
|
|
|
365
359
|
}
|
|
366
360
|
```
|
|
367
361
|
|
|
362
|
+
### Sortable - custom control
|
|
363
|
+
|
|
364
|
+
Sorting a table may also be controlled with a toolbar. This toolbar item may also be hidden at large screen sizes and only displayed when the screen size is small to support responsive tables.
|
|
365
|
+
|
|
366
|
+
```js
|
|
367
|
+
import React from 'react';
|
|
368
|
+
import { Table, TableHeader, TableBody, sortable, SortByDirection, info } from '@patternfly/react-table';
|
|
369
|
+
import {
|
|
370
|
+
Toolbar,
|
|
371
|
+
ToolbarItem,
|
|
372
|
+
ToolbarContent,
|
|
373
|
+
OptionsMenu,
|
|
374
|
+
OptionsMenuItemGroup,
|
|
375
|
+
OptionsMenuItem,
|
|
376
|
+
OptionsMenuSeparator,
|
|
377
|
+
OptionsMenuToggle
|
|
378
|
+
} from '@patternfly/react-core';
|
|
379
|
+
import SortAmountDownIcon from '@patternfly/react-icons/dist/esm/icons/sort-amount-down-icon';
|
|
380
|
+
|
|
381
|
+
class SortableTable extends React.Component {
|
|
382
|
+
constructor(props) {
|
|
383
|
+
super(props);
|
|
384
|
+
this.state = {
|
|
385
|
+
columns: [
|
|
386
|
+
{ title: 'Repositories', transforms: [sortable] },
|
|
387
|
+
{
|
|
388
|
+
title: 'Branches',
|
|
389
|
+
transforms: [
|
|
390
|
+
info({
|
|
391
|
+
tooltip: 'More information about branches'
|
|
392
|
+
}),
|
|
393
|
+
sortable
|
|
394
|
+
]
|
|
395
|
+
},
|
|
396
|
+
{ title: 'Pull requests', transforms: [sortable] },
|
|
397
|
+
{
|
|
398
|
+
title: 'Workspaces',
|
|
399
|
+
transforms: [sortable]
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
title: 'Last commit',
|
|
403
|
+
transforms: [
|
|
404
|
+
info({
|
|
405
|
+
tooltip: 'More information about commits'
|
|
406
|
+
}),
|
|
407
|
+
sortable
|
|
408
|
+
]
|
|
409
|
+
}
|
|
410
|
+
],
|
|
411
|
+
rows: [
|
|
412
|
+
['one', 'two', 'a', 'four', 'five'],
|
|
413
|
+
['a', 'five', 'k', 'two', 'three'],
|
|
414
|
+
['p', 'seven', 'b', 'one', 'six']
|
|
415
|
+
],
|
|
416
|
+
sortBy: {},
|
|
417
|
+
isSortDropdownOpen: false
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
this.onSort = this.onSort.bind(this);
|
|
421
|
+
this.onToggle = this.onToggle.bind(this);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
onSort(_event, index, direction) {
|
|
425
|
+
const sortedRows = this.state.rows.sort((a, b) => (a[index] < b[index] ? -1 : a[index] > b[index] ? 1 : 0));
|
|
426
|
+
this.setState({
|
|
427
|
+
sortBy: {
|
|
428
|
+
index,
|
|
429
|
+
direction
|
|
430
|
+
},
|
|
431
|
+
rows: direction === SortByDirection.asc ? sortedRows : sortedRows.reverse()
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
onToggle(isSortDropdownOpen) {
|
|
436
|
+
this.setState({
|
|
437
|
+
isSortDropdownOpen
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
render() {
|
|
442
|
+
const { columns, rows, sortBy, isSortDropdownOpen } = this.state;
|
|
443
|
+
|
|
444
|
+
return (
|
|
445
|
+
<React.Fragment>
|
|
446
|
+
<Toolbar id="toolbar">
|
|
447
|
+
<ToolbarContent>
|
|
448
|
+
<ToolbarItem>
|
|
449
|
+
<OptionsMenu
|
|
450
|
+
id="options-menu-multiple-options-example"
|
|
451
|
+
menuItems={[
|
|
452
|
+
<OptionsMenuItemGroup key="first group" aria-label="Sort column">
|
|
453
|
+
{columns.map((column, columnIndex) => (
|
|
454
|
+
<OptionsMenuItem
|
|
455
|
+
key={column.title}
|
|
456
|
+
isSelected={sortBy.index === columnIndex}
|
|
457
|
+
onSelect={evt => this.onSort(evt, columnIndex, sortBy.direction ? sortBy.direction : 'asc')}
|
|
458
|
+
>
|
|
459
|
+
{column.title}
|
|
460
|
+
</OptionsMenuItem>
|
|
461
|
+
))}
|
|
462
|
+
</OptionsMenuItemGroup>,
|
|
463
|
+
<OptionsMenuSeparator key="separator" />,
|
|
464
|
+
<OptionsMenuItemGroup key="second group" aria-label="Sort direction">
|
|
465
|
+
<OptionsMenuItem
|
|
466
|
+
onSelect={evt => this.onSort(evt, sortBy.index ? sortBy.index : 0, 'asc')}
|
|
467
|
+
isSelected={sortBy.direction === 'asc'}
|
|
468
|
+
id="ascending"
|
|
469
|
+
key="ascending"
|
|
470
|
+
>
|
|
471
|
+
Ascending
|
|
472
|
+
</OptionsMenuItem>
|
|
473
|
+
<OptionsMenuItem
|
|
474
|
+
onSelect={evt => this.onSort(evt, sortBy.index ? sortBy.index : 0, 'desc')}
|
|
475
|
+
isSelected={sortBy.direction === 'desc'}
|
|
476
|
+
id="descending"
|
|
477
|
+
key="descending"
|
|
478
|
+
>
|
|
479
|
+
Descending
|
|
480
|
+
</OptionsMenuItem>
|
|
481
|
+
</OptionsMenuItemGroup>
|
|
482
|
+
]}
|
|
483
|
+
isOpen={isSortDropdownOpen}
|
|
484
|
+
toggle={
|
|
485
|
+
<OptionsMenuToggle
|
|
486
|
+
hideCaret
|
|
487
|
+
onToggle={() => this.onToggle(!isSortDropdownOpen)}
|
|
488
|
+
toggleTemplate={<SortAmountDownIcon />}
|
|
489
|
+
/>
|
|
490
|
+
}
|
|
491
|
+
isPlain
|
|
492
|
+
isGrouped
|
|
493
|
+
/>
|
|
494
|
+
</ToolbarItem>
|
|
495
|
+
</ToolbarContent>
|
|
496
|
+
</Toolbar>
|
|
497
|
+
<Table aria-label="Sortable Table" sortBy={sortBy} onSort={this.onSort} cells={columns} rows={rows}>
|
|
498
|
+
<TableHeader />
|
|
499
|
+
<TableBody />
|
|
500
|
+
</Table>
|
|
501
|
+
</React.Fragment>
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
```
|
|
506
|
+
|
|
368
507
|
### Selectable with checkbox
|
|
369
508
|
|
|
370
509
|
To enable row selection, set the `onSelect` callback prop on the Table.
|
|
@@ -375,19 +514,13 @@ To disable selection for a row, set `disableSelection: true` on the row definiti
|
|
|
375
514
|
|
|
376
515
|
To include a 'select all' checkbox in the header row, pass `true` to the`canSelectAll` prop on the Table.
|
|
377
516
|
|
|
378
|
-
|
|
379
517
|
Note: this example also demonstrates the use of the `headerCol` transformation being applied to the first
|
|
380
518
|
column via the `cellTransforms` in the column definition. `headerCol` transforms the column so that instead
|
|
381
519
|
of using `td` elements, the cells in that column use `th` elements.
|
|
382
520
|
|
|
383
521
|
```js
|
|
384
522
|
import React from 'react';
|
|
385
|
-
import {
|
|
386
|
-
Table,
|
|
387
|
-
TableHeader,
|
|
388
|
-
TableBody,
|
|
389
|
-
headerCol,
|
|
390
|
-
} from '@patternfly/react-table';
|
|
523
|
+
import { Table, TableHeader, TableBody, headerCol } from '@patternfly/react-table';
|
|
391
524
|
import { Checkbox } from '@patternfly/react-core';
|
|
392
525
|
|
|
393
526
|
class SelectableTable extends React.Component {
|
|
@@ -473,20 +606,14 @@ class SelectableTable extends React.Component {
|
|
|
473
606
|
|
|
474
607
|
### Selectable radio input
|
|
475
608
|
|
|
476
|
-
To enable row radio selection, set the `onSelect` callback prop on the Table, and set `RowSelectVariant.radio` as the
|
|
609
|
+
To enable row radio selection, set the `onSelect` callback prop on the Table, and set `RowSelectVariant.radio` as the
|
|
477
610
|
`selectVariant` prop on the Table.
|
|
478
611
|
|
|
479
612
|
To disable selection for a row, set `disableSelection: true` on the row definition.
|
|
480
613
|
|
|
481
614
|
```js
|
|
482
615
|
import React from 'react';
|
|
483
|
-
import {
|
|
484
|
-
Table,
|
|
485
|
-
TableHeader,
|
|
486
|
-
TableBody,
|
|
487
|
-
RowSelectVariant,
|
|
488
|
-
headerCol,
|
|
489
|
-
} from '@patternfly/react-table';
|
|
616
|
+
import { Table, TableHeader, TableBody, RowSelectVariant, headerCol } from '@patternfly/react-table';
|
|
490
617
|
|
|
491
618
|
class SelectableTable extends React.Component {
|
|
492
619
|
constructor(props) {
|
|
@@ -629,16 +756,16 @@ class RowClickTable extends React.Component {
|
|
|
629
756
|
}
|
|
630
757
|
]
|
|
631
758
|
};
|
|
632
|
-
|
|
759
|
+
|
|
633
760
|
this.rowClickHandler = (event, row, rowProps) => {
|
|
634
761
|
this.setState(prevState => {
|
|
635
762
|
const updatedRows = [...prevState.rows];
|
|
636
763
|
updatedRows[rowProps.rowIndex].isRowSelected = !prevState.rows[rowProps.rowIndex].isRowSelected;
|
|
637
764
|
return {
|
|
638
765
|
rows: updatedRows
|
|
639
|
-
}
|
|
766
|
+
};
|
|
640
767
|
});
|
|
641
|
-
}
|
|
768
|
+
};
|
|
642
769
|
}
|
|
643
770
|
|
|
644
771
|
render() {
|
|
@@ -927,6 +1054,7 @@ To make an exapandable row, define a child row with the `parent` field set to it
|
|
|
927
1054
|
The parent row can have an `isOpen` field for managing the expanded state of the parent row.
|
|
928
1055
|
|
|
929
1056
|
Also, pass an `onCollapse` event handler via the prop on the Table
|
|
1057
|
+
|
|
930
1058
|
```js
|
|
931
1059
|
import React from 'react';
|
|
932
1060
|
import { Table, TableHeader, TableBody, TableVariant, expandable } from '@patternfly/react-table';
|
|
@@ -1086,13 +1214,14 @@ class CompactExpandableTable extends React.Component {
|
|
|
1086
1214
|
### Compound expandable
|
|
1087
1215
|
|
|
1088
1216
|
To build a compound expandable table:
|
|
1217
|
+
|
|
1089
1218
|
1. Pass the `compoundExpand` transformation via the `cellTransforms` field in the column definition for each column that will have an expanded section.
|
|
1090
1219
|
2. For each expandable parent row, the cells in the expandable columns should:
|
|
1091
|
-
|
|
1092
|
-
|
|
1220
|
+
1. have a managed `isOpen` prop passed to the cell definition
|
|
1221
|
+
2. have an `ariaControls` value which matches the `id` of it’s child row
|
|
1093
1222
|
3. For each expandable child row, the row definition needs:
|
|
1094
|
-
|
|
1095
|
-
|
|
1223
|
+
1. A `parent` field set to its parent’s row index
|
|
1224
|
+
2. A `compoundParent` field set to the cell index which will control the expanding/collapsing of this row
|
|
1096
1225
|
4. An `onExpand` event handler prop should be passed to the Table.
|
|
1097
1226
|
|
|
1098
1227
|
```js
|
|
@@ -1449,13 +1578,7 @@ class ControllingText extends React.Component {
|
|
|
1449
1578
|
|
|
1450
1579
|
```js
|
|
1451
1580
|
import React from 'react';
|
|
1452
|
-
import {
|
|
1453
|
-
Table,
|
|
1454
|
-
TableHeader,
|
|
1455
|
-
TableBody,
|
|
1456
|
-
TableText,
|
|
1457
|
-
cellWidth
|
|
1458
|
-
} from '@patternfly/react-table';
|
|
1581
|
+
import { Table, TableHeader, TableBody, TableText, cellWidth } from '@patternfly/react-table';
|
|
1459
1582
|
|
|
1460
1583
|
class ModifiersWithTableText extends React.Component {
|
|
1461
1584
|
constructor(props) {
|
|
@@ -1498,14 +1621,7 @@ class ModifiersWithTableText extends React.Component {
|
|
|
1498
1621
|
```js
|
|
1499
1622
|
import React from 'react';
|
|
1500
1623
|
import { Table, TableHeader, TableBody } from '@patternfly/react-table';
|
|
1501
|
-
import {
|
|
1502
|
-
Button,
|
|
1503
|
-
EmptyState,
|
|
1504
|
-
EmptyStateBody,
|
|
1505
|
-
Bullseye,
|
|
1506
|
-
Title,
|
|
1507
|
-
EmptyStateIcon
|
|
1508
|
-
} from '@patternfly/react-core';
|
|
1624
|
+
import { Button, EmptyState, EmptyStateBody, Bullseye, Title, EmptyStateIcon } from '@patternfly/react-core';
|
|
1509
1625
|
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
|
|
1510
1626
|
|
|
1511
1627
|
EmptyStateTable = () => {
|
|
@@ -1523,9 +1639,7 @@ EmptyStateTable = () => {
|
|
|
1523
1639
|
<Title headingLevel="h2" size="lg">
|
|
1524
1640
|
No results found
|
|
1525
1641
|
</Title>
|
|
1526
|
-
<EmptyStateBody>
|
|
1527
|
-
Clear all filters and try again.
|
|
1528
|
-
</EmptyStateBody>
|
|
1642
|
+
<EmptyStateBody>Clear all filters and try again.</EmptyStateBody>
|
|
1529
1643
|
<Button variant="link">Clear all filters</Button>
|
|
1530
1644
|
</EmptyState>
|
|
1531
1645
|
</Bullseye>
|
|
@@ -1548,13 +1662,15 @@ EmptyStateTable = () => {
|
|
|
1548
1662
|
### Editable rows
|
|
1549
1663
|
|
|
1550
1664
|
To make a table row editable:
|
|
1665
|
+
|
|
1551
1666
|
1. Pass a callback to Table via the `onRowEdit` prop.
|
|
1552
|
-
2. Define the title for the editable cells using the RowCellContent type function.
|
|
1667
|
+
2. Define the title for the editable cells using the RowCellContent type function.
|
|
1553
1668
|
3. Have the function return an `EditableTextCell`.
|
|
1554
1669
|
4. Pass the `value` and `name` of the cell's input to the `EditableTextCell` via the cell's `props` field, which is
|
|
1555
|
-
defined as being of type `EditableTextCellProps`.
|
|
1670
|
+
defined as being of type `EditableTextCellProps`.
|
|
1556
1671
|
|
|
1557
1672
|
Example:
|
|
1673
|
+
|
|
1558
1674
|
```
|
|
1559
1675
|
{
|
|
1560
1676
|
title: (value, rowIndex, cellIndex, props) => (
|
|
@@ -2038,19 +2154,13 @@ To enable favoriting of a row, set the `onFavorite` callback prop on the Table.
|
|
|
2038
2154
|
|
|
2039
2155
|
To control whether a row is favorited or not, the Table looks for `favorited: true | falsy` on the row definition.
|
|
2040
2156
|
|
|
2041
|
-
When you also pass a sort callback through the `onSort` prop, favorites sorting is also enabled.
|
|
2157
|
+
When you also pass a sort callback through the `onSort` prop, favorites sorting is also enabled.
|
|
2042
2158
|
|
|
2043
2159
|
If you want to exclude favorites from sorting, set `canSortFavorites={false}` on the Table.
|
|
2044
2160
|
|
|
2045
2161
|
```js
|
|
2046
2162
|
import React from 'react';
|
|
2047
|
-
import {
|
|
2048
|
-
Table,
|
|
2049
|
-
TableHeader,
|
|
2050
|
-
TableBody,
|
|
2051
|
-
sortable,
|
|
2052
|
-
SortByDirection
|
|
2053
|
-
} from '@patternfly/react-table';
|
|
2163
|
+
import { Table, TableHeader, TableBody, sortable, SortByDirection } from '@patternfly/react-table';
|
|
2054
2164
|
import { Checkbox } from '@patternfly/react-core';
|
|
2055
2165
|
|
|
2056
2166
|
class FavoritesTable extends React.Component {
|