How to re-run useDataGrid?
Hi, I have a use case wherein I want to re-fetch the rows of my table on a button click (after updating a value). Is there a way to manually re-run the useDataGrid hook?
Thanks!
8 Replies
Hi @krockstar. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Yes, you can manually refetch the data in your table using the
refetch
function provided by the tableQueryResult
returned from the useDataGrid
hook. The useDataGrid
hook uses the useList
hook under the hood, and the refetch
function is available from the useList
hook.
Here's an example of how you can use the refetch
function:
In this example, clicking the "Refetch Data" button will trigger the refetch
function, which will refetch the data for your table.
For more information, you can refer to the FAQ section in the refine documentation (https://refine.dev/docs/faq).
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------<@194753773376241664> kapa.ai is still learning and improving, please let us how it did by reacting below
harsh-harlequin•17mo ago
Kappa is right 👍
rival-black•17mo ago
Thanks!!
@kapa.ai refetch() does not repaint the data grid with new values though. How to solve that?
Let me check the knowledge base for you. One moment! :books:
----------------------
Hmm, I don't know enough to give you a confident answer yet. However, you can refer to the refine documentation (https://refine.dev/docs) for more information and guidance.
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------Overview | refine
What is refine?
<@194753773376241664> kapa.ai is still learning and improving, please let us how it did by reacting below
rival-black•17mo ago
@alicanerdurmaz any idea about this?
Okay I figured it out- use a local state to pass rows to the DataGrid and update this state once refetch() returns the new response