This question is locked. New answers and comments are not allowed.
Hi
When I set the ItemsSource of the RadTreeListView the first time after my silverlight 4 app has loaded. The tree is displayed correctly. Including expanded rows.
private void tlvLicMgmt_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e) { if (_ExpNodes.Contains(((LicTLstNodeData)e.Row.DataContext).NodeID)) ((TreeListViewRow)e.Row).IsExpanded = true; } If I reload the data the first row is displayed expanded but without showing the subnodes. When I click the first row the arrow changes to collapsed. When I click to expand again, the first two lines are there but almost the rest of the RadTreeListView client region is white only the last two lines are displayed too. When I click on the second node to collaps, everything starts to work fine again.
I work with Version 2010.3.1110.1040.
5 Answers, 1 is accepted
0
Luzius
Top achievements
Rank 1
answered on 21 Jan 2011, 01:13 PM
This seems to be a problem also if a node contains a large amount of subnodes. I see this behavior also when displaying a result with one top node containing about 500 subnodes (in one level, not sub sub nodes!). Is there another way the restore expanded nodes after load/reload?
0
Luzius
Top achievements
Rank 1
answered on 24 Jan 2011, 01:42 PM
I found a work around by using a DispatcherTimer.
private void tlvSwInv_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e) { if (e.Row is TreeListViewRow && e.Row.DataContext is LicTLstNodeData) { if (_ExpNodes.Contains(((LicTLstNodeData)e.Row.DataContext).NodeID)) { //((TreeListViewRow)e.Row).IsExpanded = true; ExpTlvRowDispatcherTimer ExpNodeTimer = new ExpTlvRowDispatcherTimer(); ExpNodeTimer.Interval = new TimeSpan(0, 0, 0, 0, 2); ExpNodeTimer.row = (TreeListViewRow)e.Row; ExpNodeTimer.evtHandler = new EventHandler(ExpNodeTimer_Tick); ExpNodeTimer.Tick += ExpNodeTimer.evtHandler; ExpNodeTimer.Start(); } } } void ExpNodeTimer_Tick(object sender, EventArgs e) { ((ExpTlvRowDispatcherTimer)sender).Stop(); ((ExpTlvRowDispatcherTimer)sender).row.IsExpanded = true; ((ExpTlvRowDispatcherTimer)sender).Tick -= ((ExpTlvRowDispatcherTimer)sender).evtHandler; } public class ExpTlvRowDispatcherTimer : DispatcherTimer { public TreeListViewRow row { get; set; } }0
Luzius
Top achievements
Rank 1
answered on 28 Jan 2011, 08:25 AM
The Telerik support suggested me to used the DataLoaded event to restore expanded nodes.
private void tlvLicMgmt_DataLoaded(object sender, EventArgs e) { List<string> ExpNodes = new List<string>(_ExpNodes); _ExpNodes.Clear(); foreach (String NodeID in ExpNodes) { LicTLstNodeData NodeData = GetLicTListNode(NodeID, (ObservableCollection<LicTLstNodeData>)tlvLicMgmt.ItemsSource); if (NodeData != null) { DependencyObject dpo = this.tlvLicMgmt.ItemContainerGenerator.ContainerFromItem(NodeData); if (dpo is TreeListViewRow) { if (!((TreeListViewRow)dpo).IsExpanded) { ((TreeListViewRow)dpo).IsExpanded = true; } } else { tlvLicMgmt.ExpandHierarchyItem(NodeData); } } } } private LicTLstNodeData GetLicTListNode(String NodeID, ObservableCollection<LicTLstNodeData> SubNodes) { foreach (LicTLstNodeData NodeData in SubNodes) { if (NodeID == NodeData.NodeID) return NodeData; LicTLstNodeData NodeDataSub = GetLicTListNode(NodeID, NodeData.SubNodes); if (NodeDataSub != null) return NodeDataSub; } return null; } 0
Konstantin
Top achievements
Rank 1
answered on 10 Oct 2012, 01:36 PM
_ExpNodes - what is it?
0
Luzius
Top achievements
Rank 1
answered on 22 Oct 2012, 06:44 AM
Hi Konstantin
_ExpNodes is a member variable and defined as a list of strings.
_ExpNodes is a member variable and defined as a list of strings.
List<String> _ExpNodes = new List<String>();