onFilterChange
Is there event witch can handle the filter changes?
Im currently set table state in url, for now i can track table state with these handlers.. * onChangePage | func | | To handle page changes (page) onChangeRowsPerPage | func | | To handle rows per page changes (pageSize) onOrderChange | func | | To handle order changes (orderedColumnId, orderDirection) onRowClick | func | | To handle row click (event, rowData) *
but i also need to set filter params in state but i cant handle changes in them... any suggestions how can i track this event ?
Hi @rayray93 ,
Did you see remote data feature? It lets you to manage all events.
https://mbrn.github.io/material-table/#/docz-examples-14-example-remote-data
@mbrn Thanks u for response :)
Yes, i saw feature but problem is when i navigate away from that table and came back im loosing page, pageSize, filters.. etc.
so i switch to static data, so i fetch(fetching by url) data in array assign it to table data and then handle url by events onPageChange, onSortChange etc but there is no event for filterChange...
so far i get my table state via url when i navigate away and came back but still need that filter params in url..
any suggestion how to handle this? Thanks
I got your requirement. I will add this event asap.
As a workaround you can do this:
<MaterialTable
components={{
Body: props => <MTableBody {...props} onFilterChanged={(columnId, value) => {
props.onFilterChanged(columnId, value);
// Do you job here :)
}}/>
}}
.....
/>
How do you implement a debounce in this situation? when is trigger this function is after the debounce ?
Best Regards
This is a workaround. so in this solution i avoid the debounce.
customFilterAndSearch have a debounce ?
yes, table calls customFilterAndSearch in a debounce.
Hi, I tried your workaround as in here: import MTableBody from 'material-table'; .... <MaterialTable components={{ Body: props => <MTableBody {...props} onFilterChanged={(columnId, value) => { props.onFilterChanged(columnId, value); // Do you job here :) }}/> }}
but the page won't render, in hanging stage. Any idea?
Another question, how soon do you think you will have a release for this feature?
Thanks much in advance.
use this:
import MaterialTable, { MTableBody} from 'material-table';
After resolving a few issues i will publish a new release. It generally takes a few days. But nowadays i am very busy. I hope that i will publish a new release asap.
sorry about the stupid questions, I am pretty new to react.
I have this error
Uncaught TypeError: Cannot read property 'paging' of undefined, at MTableBody.render....
And quick pointer is much appreciated.
No problem @rayray93 ,
Did you use this?
{...props}
Yes, exactly as here: <MaterialTable components={{ Body: props => <MTableBody {...props} onFilterChanged={(columnId, value) => { props.onFilterChanged(columnId, value); // Do you job here :) }}/> }}
components={{
Toolbar: props => <MTableBody {...props} onFilterChanged={(columnId, value) => {
props.onFilterChanged(columnId, value);
// Do you job here :)
}}/>
}}
options={{
pageSize:10,
paging:false,
exportButton:true,
columnsButton:true,
pageSizeOptions:[10,20,30],
actionsColumnIndex: -1,
rowStyle:{height:"20px"},
maxBodyHeight: 700,
filtering:true,
}}
I have the paging prop specified above, have no idea why it won't pass, with this error msg: bundle.js:82021 Uncaught TypeError: Cannot read property 'paging' of undefined
Any idea? Thanks.
components={{ Toolbar: props => <MTableBody options={{ pageSize:10, paging:false, }} {...props} onFilterChanged={(columnId, value) => { props.onFilterChanged(columnId, value); debugger // Do you job here :) }} /> }}
Got a little closer by moving options inside of Toolbar component, now I got error: Uncaught TypeError: _this2.props.getFieldValue is not a function
No. This is not a good solutions. props should contain these fields. Can you check props please? Rename it to avoid name conflicts
@mbrn Why did you close this? Did you implement this already? Otherwise I would be ready to open a MR.
Hi @a544jh
Hi, I tried your workaround as in here: import MTableBody from 'material-table'; .... <MaterialTable components={{ Body: props => <MTableBody {...props} onFilterChanged={(columnId, value) => { props.onFilterChanged(columnId, value); // Do you job here :) }}/> }}
but the page won't render, in hanging stage. Any idea? Another question, how soon do you think you will have a release for this feature?
Thanks much in advance.
I think this is a solution for this case.
@mbrn Hi Sir, I start working with meterial-table and i found it great. Thanks for your work but i facing issue while using onOrderChange prop. This call back is not working and not showing any data of orderBy and orderDirection. if i got it right is this handle event of drag column position and one thing more please give a prop for custom ordering and selection of columns in your next Update. thanks in advance
@mbrn - I'm trying to use your workaround with the custom Body component onFilterChanged behavior. I'm running into an issue though when trying to set state on my component in the event handler. Using a hook or a redux action causes the table to 'reset'? I type a filter and the event is handled, but as soon as the call is made that reaches out of the scope of the handler, the table clears.
here's my code:
components={{
Body: bodyProps => (
<MTableBody
{...bodyProps}
onFilterChanged={(columnId: number, value: string) => {
// get column's fieldName
// get data whose prop has same value as filter
// redux action, tried using local hook for state as well
props.setSummaryData(matchingRows);
bodyProps.onFilterChanged(columnId, value);
}}
/>),
}}
and here's the behavior I'm seeing:

I'm gonna put this on an open issue