load on demand in TreeList

1 Answer 43 Views
TreeList
Andrei
Top achievements
Rank 1
Andrei asked on 28 Nov 2023, 03:11 PM

Hello Telerik, 

Is there any way to make child elements load on demand only in expand event, and control the expand status depending on data?

1 Answer, 1 is accepted

Sort by
0
Accepted
Filip
Telerik team
answered on 30 Nov 2023, 11:42 AM

Hi, Andrei,

Load on demand can be achieved inside the onExpandChange event since it provides a level prop (an array that has all the indexes of the parent items). It can be used inside the getItemPath function which returns the expanded node and the parent. This way by obtaining the expanded `dataItem` you can make a request from the server and add its sub-items:

onExpandChange = (e) => {
    const items = getItemPath(data, e.level, subItemsField);
    const expandedItem = items.pop();
    const parent = items.pop();
}

We also have logged a GitHub issue for a load-a-demand demo that can be tracked and monitored here:

https://github.com/telerik/kendo-react/issues/737

I have added your request to the item in order to increase its priority.

Regards,
Filip
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources!

Tags
TreeList
Asked by
Andrei
Top achievements
Rank 1
Answers by
Filip
Telerik team
Share this question
or