I have a RadzenTree on the page with data which is multilanguage and dropdown for language selection. Data is loaded in the tree control on demand - no issues with that.
Children data is loaded with the code
private async Task OnTreeNodeExpand(TreeExpandEventArgs args)
{
if (args.Value is MyTreeItem item)
{
args.Children.Data = ##Getting data here
args.Children.TextProperty = "NamePlural";
args.Children.HasChildren = ((i) => ((MyTreeItem)i).HasChildren);
args.Children.Template = TreeItemTemplate;
}
}
When i am changing language selection in drop down, i am reloading the root level data. Root level items are updated on UI, but old children are still there.
Any ideas how can i remove them or reload in a proper way?
Example.
Original tree in English
After switching to French, root level is get updated, but opened children not.
This is how tree is looking, if i will collapse "First plural" node and open it again while French language is active.
P.S. I have also tried to keep a track of loaded children data in the dictionary, and reload all of them on the language changed. Tree behavior is the same as described above
private async Task OnTreeNodeExpand(TreeExpandEventArgs args)
{
if (args.Value is MyTreeItem item)
{
if (_loadedTreeItems.ContainsKey(item.Id))
{
_loadedTreeItems[item.Id] = ##Loading data here##
}
else
{
var childrenData = ##Loading data here##
_loadedTreeItems.Add(item.Id, childrenData);
}
args.Children.Data = _loadedTreeItems[item.Id];
args.Children.TextProperty = "NamePlural";
args.Children.HasChildren = ((i) => ((MyTreeItem)i).HasChildren);
args.Children.Template = TreeItemTemplate;
}
}
Thank you for reply.
Will try to do a separate solution with hard coded data and upload it somewhere.
For now i "got solved" the issue by doing a trick, when language is changed i am doing
_rootLevelData = null;
_rootLevelData = ###loading data###
Such a way all data nodes are collapsed and root level is reloaded.
I hope it will be understandable.
There is one more page with Selected issue. When Selected set programmatically, with a mouse click on the node it is missing "ui-treenode-content-selected" class. It might be i do something wrong.
I've made some changes in the treeview so a node renders its children if its Value property changes and the node was expanded. The fix will be available with the next Radzen release.