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
// Controlled State Overrides (see Fully Controlled Component section)
148
151
page:undefined,
@@ -154,6 +157,7 @@ These are all of the available props (and their default values) for the main `<R
154
157
onPageChange:undefined,
155
158
onPageSizeChange:undefined,
156
159
onSortingChange:undefined,
160
+
onFilteringChange:undefined,
157
161
158
162
// Pivoting
159
163
pivotBy:undefined,
@@ -184,6 +188,9 @@ These are all of the available props (and their default values) for the main `<R
184
188
getTheadProps: () => ({}),
185
189
getTheadTrProps: () => ({}),
186
190
getTheadThProps: () => ({}),
191
+
getTheadFilterProps: () => ({}),
192
+
getTheadFilterTrProps: () => ({}),
193
+
getTheadFilterThProps: () => ({}),
187
194
getTbodyProps: () => ({}),
188
195
getTrGroupProps: () => ({}),
189
196
getTrProps: () => ({}),
@@ -215,7 +222,8 @@ These are all of the available props (and their default values) for the main `<R
215
222
footer:undefined,
216
223
footerClassName:'',
217
224
footerStyle: {},
218
-
getFooterProps: () => ({})
225
+
getFooterProps: () => ({}),
226
+
filterMethod:undefined
219
227
},
220
228
221
229
// Text
@@ -292,8 +300,13 @@ Or just define them as props
292
300
footer:'Header Name' or JSX eg. ({data, column}) =><div>Header Name</div>,
293
301
footerClassName:'', // Set the classname of the `td` element of the column's footer
294
302
footerStyle: {}, // Set the style of the `td` element of the column's footer
295
-
getFooterProps: (state, rowInfo, column, instance) => ({}) //a function that returns props to decorate the `td` element of the column's footer
303
+
getFooterProps: (state, rowInfo, column, instance) => ({}) //A function that returns props to decorate the `td` element of the column's footer
296
304
305
+
// Filtering
306
+
filterMethod: (filter, row, column) => {returntrue} // A function returning a boolean that specifies the filtering logic for the column
307
+
// filter == an object specifying which filter is being applied. Format: {id: [the filter column's id], value: [the value the user typed in the filter field]}
308
+
// row == the row of data supplied to the table
309
+
// column == the column that the filter is on
297
310
}]
298
311
```
299
312
@@ -532,7 +545,7 @@ By adding a `SubComponent` props, you can easily add an expansion level to all r
532
545
533
546
534
547
## Server-side Data
535
-
If you want to handle pagination, and sorting on the server, `react-table` makes it easy on you.
548
+
If you want to handle pagination, sorting, and filtering on the server, `react-table` makes it easy on you.
536
549
537
550
1. Feed React Table `data` from somewhere dynamic. eg. `state`, a redux store, etc...
538
551
1. Add `manual` as a prop. This informs React Table that you'll be handling sorting and pagination server-side
@@ -555,7 +568,8 @@ If you want to handle pagination, and sorting on the server, `react-table` makes
555
568
Axios.post('mysite.com/data', {
556
569
page:state.page,
557
570
pageSize:state.pageSize,
558
-
sorting:state.sorting
571
+
sorting:state.sorting,
572
+
filtering:state.filtering
559
573
})
560
574
.then((res) => {
561
575
// Update react-table
@@ -601,6 +615,7 @@ Here are the props and their corresponding callbacks that control the state of t
601
615
onPageSizeChange={(pageSize, pageIndex) => {...}} // Called when the pageSize is changed by the user. The resolve page is also sent to maintain approximate position in the data
602
616
onSortingChange={(column, shiftKey) => {...}} // Called when a sortable column header is clicked with the column itself and if the shiftkey was held. If the column is a pivoted column, `column` will be an array of columns
603
617
onExpandRow={(index, event) => {...}} // Called when an expander is clicked. Use this to manage `expandedRows`
618
+
onFilteringChange={(column, event) => {...}} // Called when a user enters a value into a filter input field. The event is the onChange event of the input field.
0 commit comments