Skip to content

Commit 9d9b1fd

Browse files
Enhance pivots (TanStack#224)
* Prevent transitions while resizing for a smoother effect. * Disable text selection when resizing columns * Use PivotValueComponent instead of pivotRender * Add changelog file
1 parent ab1c020 commit 9d9b1fd

File tree

7 files changed

+335
-359
lines changed

7 files changed

+335
-359
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## 6.0.0
2+
3+
* Pivot Columns can now be sorted and filtered individually.
4+
* More control over Pivot Column rendering.
5+
* Prevent transitions while column resizing for a smoother resize effect.
6+
* Disable text selection while resizing columns.
7+
8+
##### Breaking API Changes
9+
* Removed `pivotRender` column option. You can now control how the value is displayed by overriding the `PivotValueComponent`.
10+
* Changed how special `expander: true` column renders pivot columns.
11+
See [Pivoting Options Story](https://react-table.js.org/?selectedKind=2.%20Demos&selectedStory=Pivoting%20Options&full=0&down=1&left=1&panelRight=0&downPanel=kadirahq%2Fstorybook-addon-actions%2Factions-panel) for a reference on how to customize pivot column rendering.

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ These are all of the available props (and their default values) for the main `<R
182182

183183
// Pivoting
184184
pivotBy: undefined,
185-
pivotColumnWidth: 200,
186185
pivotValKey: '_pivotVal',
187186
pivotIDKey: '_pivotID',
188187
subRowsKey: '_subRows',
@@ -268,7 +267,8 @@ These are all of the available props (and their default values) for the main `<R
268267

269268
// Global Pivot Column Defaults
270269
pivotDefaults: {
271-
// render: will be overriden in methods.js to display ExpanderComponent
270+
filterRender: undefined
271+
// render: will be overriden in methods.js to display ExpanderComponent and PivotValueComponent
272272
},
273273

274274
// Text
@@ -578,7 +578,7 @@ const columns = [{
578578
}]
579579
```
580580

581-
Pivoted columns can be sorted just like regular columns, but not independently of each other. For instance, if you click to sort the pivot column in ascending order, it will sort by each pivot recursively in ascending order together.
581+
Pivoted columns can be sorted just like regular columns including holding down the `<shift>` button to multi-sort.
582582

583583
## Sub Tables and Sub Components
584584
By adding a `SubComponent` props, you can easily add an expansion level to all root-level rows:
@@ -742,6 +742,7 @@ Object.assign(ReactTableDefaults, {
742742
TdComponent: component,
743743
TfootComponent: component,
744744
ExpanderComponent: component,
745+
PivotValueComponent: component,
745746
PaginationComponent: component,
746747
PreviousComponent: undefined,
747748
NextComponent: undefined,

src/defaultProps.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ export default {
4444

4545
// Pivoting
4646
pivotBy: undefined,
47-
pivotColumnWidth: 200,
4847
pivotValKey: '_pivotVal',
4948
pivotIDKey: '_pivotID',
5049
subRowsKey: '_subRows',
@@ -129,7 +128,8 @@ export default {
129128

130129
// Global Pivot Column Defaults
131130
pivotDefaults: {
132-
// render: will be overriden in methods.js to display ExpanderComponent
131+
filterRender: undefined
132+
// render: will be overriden in methods.js to display ExpanderComponent and PivotValueComponent
133133
},
134134

135135
// Text
@@ -162,13 +162,14 @@ export default {
162162
},
163163
TdComponent: _.makeTemplateComponent('rt-td'),
164164
TfootComponent: _.makeTemplateComponent('rt-tfoot'),
165-
ExpanderComponent: ({isExpanded}) => {
166-
return (
167-
<div className={classnames('rt-expander', isExpanded && '-open')}>
168-
&bull;
169-
</div>
170-
)
171-
},
165+
ExpanderComponent: ({isExpanded}) => (
166+
<div className={classnames('rt-expander', isExpanded && '-open')}>
167+
&bull;
168+
</div>
169+
),
170+
PivotValueComponent: ({subRows, value}) => (
171+
<span>{value} {subRows && `(${subRows.length})`}</span>
172+
),
172173
PaginationComponent: Pagination,
173174
PreviousComponent: undefined,
174175
NextComponent: undefined,

0 commit comments

Comments
 (0)