This is a migrated thread and some comments may be shown as answers.

Expanding 1000+ items freezes application

3 Answers 177 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Jinyan
Top achievements
Rank 1
Jinyan asked on 21 Aug 2012, 08:43 PM
My application freezes when I try to expand a node on RadTreeView that has over 1000 children. Is there anyway to avoid this? I tried using on-demand loading and it doesn't seem to do anything. So it makes me believe that it's the rendering part of the treeview that is clogging the CPU.

Thanks,
Jin

3 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 22 Aug 2012, 08:00 AM
Hello Jin,

Do you databind the RadTreeView control? If so, can you make sure it is virtualized - you can examine this feature here. If this suggestion doesn't help, can you try to isolate the issue in a sample solution and send it over so that we can take a look at it? Thank you in advance.

Greetings,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Jinyan
Top achievements
Rank 1
answered on 22 Aug 2012, 10:23 PM
That partly solved the issue. Here is my full scenario

My metadata are as follows:

class A
{
    ObservableCollection<B> Bs;
    ObservableCollection<C> Cs;
 
    string name;
}
 
class B { string name; }
 
class C { string name; }

My templates are as follows
<!-- NORMAL TREE STRUCTURE A - B - C -->
<DataTemplate x:Key="CTemplate">
    <TextBlock Text="{Binding Name}" />
</DataTemplate>
 
<HierarchicalDataTemplate x:Key="BTemplate"
            ItemsSource="{Binding Path=DataContext.Cs, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik:RadTreeViewItem}, AncestorLevel=1}}"
            ItemTemplate="{StaticResource CTemplate}">
    <TextBlock Text="{Binding Name}" />
</HierarchicalDataTemplate>
 
<HierarchicalDataTemplate x:Key="ATemplate"
            ItemsSource="{Binding Path=Bs}"
            ItemTemplate="{StaticResource BTemplate}">
    <TextBlock Text="{Binding Name}" />
</HierarchicalDataTemplate>
 
 
<!-- REVERSE TREE STRUCTURE A - C - B -->
<DataTemplate x:Key="ReverseBTemplate">
    <TextBlock Text="{Binding Name}" />
</DataTemplate>
<HierarchicalDataTemplate x:Key="ReverseCTemplate"
      ItemsSource="{Binding Path=DataContext.Bs, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik:RadTreeViewItem}, AncestorLevel=1}}"
      temTemplate="{StaticResource ReverseBTemplate}" >
    <TextBlock Text="{Binding Name}" />
</HierarchicalDataTemplate>
<HierarchicalDataTemplate x:Key="ReverseATemplate"
            ItemsSource="{Binding Path=Cs}"
            ItemTemplate="{StaticResource ReverseCTemplate}">
    <TextBlock Text="{Binding Name}" />
</HierarchicalDataTemplate>


C is the level of tree that contains a lot of items.

Essentially, I have a normal tree where the data is organized as A - B - C, and I have a button when the user clicks it changes the DataTemplate to the ReverseATemplate, and reorganizes the tree to A - C - B. In the normal tree structure, everything works perfectly and loading of C data is almost instantaneous. However, when I reverse the tree, loading the C level takes maybe 2 seconds if number of Cs is greater than 1000. Furthermore, scrolling down the tree is now quite laggy.

Do you have any insights as to why this is happening, and maybe insights on a more elegant solution for changing the tree hierarchy?

Thanks so much for the help.
Jin
0
Tina Stancheva
Telerik team
answered on 27 Aug 2012, 02:03 PM
Hi Jin,

I am not sure I understand your scenario correctly so I attached a sample solution based on your code samples. Can you please have a look at it and modify it to better demonstrate your approach? Thank you in advance.

Greetings,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
TreeView
Asked by
Jinyan
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Jinyan
Top achievements
Rank 1
Share this question
or