RadTreeListView after reload not displaying correctly

6 posts, 0 answers
  1. Luzius
    Luzius avatar
    14 posts
    Member since:
    Jun 2010

    Posted 20 Jan 2011 Link to this post

    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.

  2. Luzius
    Luzius avatar
    14 posts
    Member since:
    Jun 2010

    Posted 21 Jan 2011 Link to this post

    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?
  3. DevCraft banner
  4. Luzius
    Luzius avatar
    14 posts
    Member since:
    Jun 2010

    Posted 24 Jan 2011 Link to this post

    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; }
    }

  5. Luzius
    Luzius avatar
    14 posts
    Member since:
    Jun 2010

    Posted 28 Jan 2011 Link to this post

    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
  6. Konstantin
    Konstantin avatar
    2 posts
    Member since:
    Oct 2012

    Posted 10 Oct 2012 Link to this post

    _ExpNodes - what is it? 
  7. Luzius
    Luzius avatar
    14 posts
    Member since:
    Jun 2010

    Posted 22 Oct 2012 Link to this post

    Hi  Konstantin

    _ExpNodes is a member variable and defined as a list of strings.
    List<String> _ExpNodes = new List<String>();

Back to Top
DevCraft banner