From what I can see, currently the only way to set the expanded items for a TreeList is through the state.
The main problem is that the state doesn't fire the OnExpand event, meaning that if you have a server loaded tree you need to make sure to load the data before each item is expanded. It also allows for duplicates in the 'ExpandedItems' if you don't check for duplicates before adding to it.
The TreeView has an 'ExpandedItems' parameter that can be bound which is a bit nicer than using the state, but from my quick test this also doesn't fire the OnExpand event.
My request is for one of the following to be added:
Issue - While restoring the tree list state from local storage any items that were expanded are not re-expanded
Repo - https://github.com/benhysell/BlazorGridPagingIssue
Example Inspired By - https://docs.telerik.com/blazor-ui/components/treelist/state#save-and-load-treelist-state-from-browser-localstorage
Steps to Reproduce
Expected behavior - Elements that had been expanded would be expanded again.
Details
Following the example https://docs.telerik.com/blazor-ui/components/treelist/state#save-and-load-treelist-state-from-browser-localstorage I copied the code into my application, however I wanted to save which items were expanded, so I commented out:
state.ExpandedItems = null;
Looking at the resulting entries in local storage, it appears the ExpandedItems list is properly saved to local storage.
I added some logging to the OnStateInitHandler so I could see what was happening on load, my desired result was to ensure:
It appears everything is going out to local storage, and coming back in without issue, however the state of the expanded items is not reflected in the control.
I use Guids to identify data in my application. It is a lot more reliable than using integers; however, it appears as if the TreeList does not support the use of Guids for the Id and ParentId fields when building the list's view.
---
ADMIN EDIT
This was not a bug, it was probably a configuration issue, as the scenario works, so this is marked as "declined". See the thread below for a sample.
---