I am trying to implement a search feature on a TreeView. For my search, I am receiving a list of paths to the correct nodes on the tree.
The challenge comes in that I need to use lazy loading for my remote data source. I need to know when the data is loaded and the node has finished expanding or I need the ability to trigger the expansion of a node once the data for that node has loaded.
I've tried doing this with the fetch function but that doesn't seem to work properly. Since the search returns multiple results, I have a loop call my search function iteratively. What appears to happen is that the loop progresses without finishing a call until the last element because the data has not loaded from the remote data source until that time. I believe it may have something to do with calling both fetch and then expand afterward.
Does the expand function implement the Promise API? Is there another way to make this work?
My code is the following:
// - the first level dataItem
// - the number 1