Lazy loading expanded rows
See original GitHub issueCurrently noting that the getSubRows
prop does not get recalled automatically after row expansion click occurs while using the useExpanded
plugin. This makes lazy loading less than ideal on my side, i.e. I’d like to show a loading indicator in the child row after parent expansion click occurs, and then re-render the child row after I get the response w/ data. Any suggestions here?
This can certainly be achieved manually by doing a combination of the following:
- wiring up expansion click callbacks on the expansion cell
- rendering the child loading spinner in the child with a “custom sub component” like this example: https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/sub-components
- Fetching the data and updating the
data
prop for the child row, but ensuring the other row expansion states do not change after reload: https://github.com/tannerlinsley/react-table/blob/2a0dc6778df1725358486b576f553e1ba2dc3489/docs/faq.md#how-do-i-stop-my-table-state-from-automatically-resetting-when-my-data-changes
Am I approaching this correctly? Just checking this vs what’s currently available here. Would be great to have some kind of better way in the future if this is the case…
Thanks for any advice!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Lazy loading expanded rows · Issue #1884 · TanStack/table
This makes lazy loading less than ideal on my side, i.e. I'd like to show a loading indicator in the child row after...
Read more >Lazy-Loading Expandable Rows with React Table - Medium
We use the Cell property to instruct React Table on how it should format an individual cell, in this instance, we add an...
Read more >Table with expandable rows with 'lazy rendering' - angular ...
I want to implement lazy loading on a material table with expandable rows. load the expanded data only after the row was clicked....
Read more >Row Expander | Lazy Loading | JET Developer Cookbook
Enable hierarchical data to be displayed in a JET Table. This demo gives an overview of RESTTreeDataProvider in a oj-table using oj-row-expander.
Read more >How to expand all grouped rows when using LazyLoading
By default, the lazy load grouping allows you to load grouped records to the Grid through the on-demand concept.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Update: I PRed an example in #2531
I’ve implemented this through checking if a row is expanded with the following:
renderRowSubComponent
is a function that returns a ReactNode. I use it to passrow.original.customExtraData
to a subRow component.I then created a sub row common component that will use the existing Cell or if given in the column config, a SubCell. Note, the implementation below assumes the
accessor
is a function, it could be adapted to allow for strings if desired as well.I hope this helps, it took many many failed attempts before I got to this approach, which has worked out really well!