How to create subgrid and to load data into it from server only when its subrow is opened for the first time? Preserve option is set to true.
Hello.
Here you can find the example where the subgrid data loads from the external json on subrow expanding:
https://snippet.dhtmlx.com/03ndqrqt
Yes, but that example does not work. Add preserve option and remove expand call and you see in browser console that data is immediately loaded to ALL subgrids. That must not happen.
I see.
In this case you may try to apply the “preserve” property only to the rows that were expanded.
subRowConfig property can be used as a function that gets the current row as a parameter:
So you may use:
subRowConfig: (row) => ({
preserve: row.$opened,
}),
to enable the preserve to the opened rows.
Here is the updated example:
https://snippet.dhtmlx.com/g34v9zds
That seems to work.
Is there a way to set height of subrow dynamically based on its content to minimize unnecessary scrolling and empty space? Like in previous example bird paradise has five animals, aquatic world has three animals and no data has no subgrid so need to display that content varies. Optimally they should only take space they need (to a point). Could configuration be defined like: { height: “auto”, maxHeight: 400 }?
In case of external data loading to the subgrid there is no possibility to calculate the expected height for the subrow in its config.
In this case I can only suggest you to use the pagination with some median height. Like:
https://snippet.dhtmlx.com/1aq36b7t