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

How to combine IsLoadOnDemandEnabled="True" with Hierarchical Templates

2 Answers 73 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Karanjit Siyan
Top achievements
Rank 1
Karanjit Siyan asked on 28 May 2010, 07:30 PM
If I set IsLoadOnDemandEnabled="True" on the RadTreeView, it sets the Expander node for all items in the tree including the leaf node. This is as it should be according to the documentation. Howerver, I have a tree that is constructed using Hierarchical templates. I want to set the IsLoadOnDemandEnabled="True" for only some of the nodes in the hierarchy. I can get this to work by setting the IsLoadOnDemandEnabled=True for the entire tree. However this puts the expander on all nodes including the last one (the leaf nodes). I don't want the expander in the leaf nodes. How to disable this?

You can use the sample in the documentation -- and set IsLoadOnDemandEnabled="True" at the tree level, then try to set IsLoadOnDemandEnabled="True" at an intermediate node, or turn it off at the leaf nodes. I have tried to obtain the individual RadTreeViewItem and set the IsLoadOnDemandEnabled to False for the leaf node, but I still see the expander icon.


http://demos.telerik.com/silverlight/#TreeView/HierarchicalTemplate

 

 

 

<telerik:HeaderedContentControl

 

 

 

 

HorizontalAlignment="Center"

 

 

 

 

 

 

VerticalAlignment="Center"

 

 

 

 

 

Header="Leagues"

 

 

 

 

 

 

HorizontalContentAlignment="Stretch"

 

 

 

 

 

 

VerticalContentAlignment="Stretch"

 

 

 

 

 

 

Height="410">

 

 

 

 

 

 

 

 

 

<telerikNavigation:RadTreeView

 

 

 

 

ExpanderStyle="{StaticResource ExpanderStyle1}"

 

 

 

 

 

ItemTemplateSelector="{StaticResource myDataTemplateSelector}"

 

 

 

 

 

ItemsSource="{Binding Source={StaticResource MyList}}"

 

 

 

 

 

Margin="5"
IsLoadOnDemandEnabled
="True" />  <!-- This is the property that needs to be set selectively -->

 

 

 

 

 

 

 

 

 

</telerik:HeaderedContentControl>

 

 

 

 


2 Answers, 1 is accepted

Sort by
0
Karanjit Siyan
Top achievements
Rank 1
answered on 29 May 2010, 05:44 AM
I fixed the issue that I just described by adding a handler for ItemsPrepared:

 

 

private void xxxx_ItemPrepared(object sender, RadTreeViewItemPreparedEventArgs e)

 

{

 

 

    RadTreeViewItem item = (RadTreeViewItem)e.PreparedItem;

 

 

 

    if (item.Item is FileNode)

 

    {

        item.IsLoadOnDemandEnabled =

 

false;

 

    }

}

0
Bobi
Telerik team
answered on 02 Jun 2010, 10:43 AM
Hello Karanjit Siyan,

You can also take a look at the following online example that demonstrates the usage of LoadOnDemand with HierarchicalTemplate:
http://demos.telerik.com/silverlight/#TreeView/LoadOnDemand

Greetings,
Bobi
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
TreeView
Asked by
Karanjit Siyan
Top achievements
Rank 1
Answers by
Karanjit Siyan
Top achievements
Rank 1
Bobi
Telerik team
Share this question
or