File tree 3 files changed +18
-2
lines changed 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -447,8 +447,19 @@ export default class MaterialTable extends React.Component {
447
447
448
448
this . onQueryChange ( query ) ;
449
449
}
450
- else {
451
- this . setState ( this . dataManager . getRenderState ( ) ) ;
450
+ else {
451
+ this . setState ( this . dataManager . getRenderState ( ) , ( ) => {
452
+ if ( this . props . onFilterChange ) {
453
+ const appliedFilters = this . state . columns
454
+ . filter ( a => a . tableData . filterValue )
455
+ . map ( a => ( {
456
+ column : a ,
457
+ operator : "=" ,
458
+ value : a . tableData . filterValue
459
+ } ) ) ;
460
+ this . props . onFilterChange ( appliedFilters ) ;
461
+ }
462
+ } ) ;
452
463
}
453
464
} , this . props . options . debounceInterval )
454
465
Original file line number Diff line number Diff line change @@ -166,6 +166,7 @@ export const propTypes = {
166
166
} ) ,
167
167
initialFormData : PropTypes . object ,
168
168
onSearchChange : PropTypes . func ,
169
+ onFilterChange : PropTypes . func ,
169
170
onColumnDragged : PropTypes . func ,
170
171
onGroupRemoved : PropTypes . func ,
171
172
onSelectionChange : PropTypes . func ,
Original file line number Diff line number Diff line change @@ -30,6 +30,10 @@ export interface MaterialTableProps<RowData extends object> {
30
30
onRowClick ?: ( event ?: React . MouseEvent , rowData ?: RowData , toggleDetailPanel ?: ( panelIndex ?: number ) => void ) => void ;
31
31
onRowSelected ?: ( rowData : RowData ) => void ;
32
32
onSearchChange ?: ( searchText : string ) => void ;
33
+ /** An event fired when the table has finished filtering data
34
+ * @param {Filter<RowData>[] } filters All the filters that are applied to the table
35
+ */
36
+ onFilterChange ?: ( filters : Filter < RowData > [ ] ) => void ;
33
37
onSelectionChange ?: ( data : RowData [ ] , rowData ?: RowData ) => void ;
34
38
onTreeExpandChange ?: ( data : any , isExpanded : boolean ) => void ;
35
39
onQueryChange ?: ( query : Query < RowData > ) => void ;
You can’t perform that action at this time.
0 commit comments