I have a tree with dynamic loading enabled. I need to open a specific path inside the tree programmatically. The problem is that after calling open(id) on the tree, there is no built-in way to know when the node has actually been opened.
Currently, I have two options:
Use window.setTimeout() to proceed every 500ms, which is very slow and may fail if the request takes too long
Send the entire path to the server and let it return the required part of the tree in one request (Edit: This doesn’t even work since I can’t control the request sent by open())
It is possible but not trivial.
Check the next snippet Code Snippet
It uses onDataRequest to set the promise and in onAfterOpen it runs the code only when promise is resolved. As result you can call any operations against child items and it will work for both loaded and not loaded yet branches.
This doesn’t even work since I can’t control the request sent by open
You can use onDataRequest event to intercept the data loading call and replace it with custom ajax call