Material-table: Ability to force a data request based on input outside of the table

Created on 12 Mar 2019  路  6Comments  路  Source: mbrn/material-table

When I was doing my own server side pagination, data was based on the state's data, but now that the function to fetch the data is called on render, I'm not sure how to toggle a fetch when inputs are submitted outside of the table that can also be used to filter the data. Suggestions on how to go about this?

enhancement

Most helpful comment

Hi,

I added a tableRef feature to table. So you can call onQueryChange from outside of table. Please look at #383

Don't forget to upgrade 1.28.0

All 6 comments

I will think about.

Not the best of options, but something short term might be having access to triggering a data query based on the toolbar or from free actions.

Hi @mbrn ,

I am doing my own server-side filter, sort, and search actions too. If you could open an onQueryChange or handleQueryChange function to triggering a data query based on remote data mode. That will give me the ability to use my own filter UI. For the onQueryChange function, I expect an attribute as a current query object and will return a new query object and will triggering a data query. I am not sure that this is the best way to do.
What do you think?

Hi @hcsgzh ,

It already call data (think it as onQueryChange) on every change on table. It is expect data from you.

Additionally you want to return query too. Am i right?

Then i will set your query to table.

Hi,

What I did as a temporary solution was to have a component that extends MaterialTable. It has a function that calls onQueryChange(this.state.query) and I pass this function in the constructor to one that's received as a prop. Then I can save the reference of that function outside of the component and I can trigger it manually whenever I want.

This stopped working however since withStyles was added to MaterialTable, so I'm stuck with v1.23.3 for the time being.

Hi,

I added a tableRef feature to table. So you can call onQueryChange from outside of table. Please look at #383

Don't forget to upgrade 1.28.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bohrsty picture bohrsty  路  3Comments

slevy85 picture slevy85  路  3Comments

KKrisu picture KKrisu  路  3Comments

diegosps picture diegosps  路  3Comments

jlgreene2 picture jlgreene2  路  3Comments