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

Few questions about IsLoadOnDemandEnabled

4 Answers 139 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Lauren Nickerson
Top achievements
Rank 1
Lauren Nickerson asked on 05 Aug 2010, 02:43 AM
First question:

Is it possible to have IsLoadOnDemand = true but NOT show the arrows on some items? (The arrows that indicate the items have items themselves). Not all our items have children, so we don't want to show the arrows in all of the items.

http://www.screencast.com/users/CarloToribio/folders/Jing/media/abe8d5f6-a1f0-4776-9812-b709f3ff4c97

Second question:

How can I make the items show the loading animation while I'm doing something in the LoadOnDemand event? We're trying to deserialize some objects in there, and it might take a second or two, but the animation doesn't show up, it just freezes for those two seconds. I tried it this way but no luck:

private void treeView_LoadOnDemand(object sender, RadRoutedEventArgs e)
{
    RadTreeViewItem clickedItem = e.Source as RadTreeViewItem;
 
    clickedItem.Dispatcher.BeginInvoke(new ThreadStart(delegate
        {
            clickedItem.Items.Add(new RadTreeViewItem() { Header = clickedItem.Header + "." + (clickedItem.Items.Count + 1) });
 
            Thread.Sleep(2000);
        }));
}

Any suggestions?

Thanks.

Thanks.

4 Answers, 1 is accepted

Sort by
0
Sushil
Top achievements
Rank 1
answered on 07 Aug 2010, 02:11 AM
Hi,

I am having similar problem with the arrows.

Looking forward to any suggestions...

Thanks,
0
Miroslav
Telerik team
answered on 10 Aug 2010, 11:29 AM
Hi Lauren & Sushil,

You can turn off the arrows by setting the IsLoadOnDemandEnabled = false for a given item.

A good place to do this is the ItemPrepared event since there you have both the item and the business object. Of course you need to have a property that indicates whether the object has children.

When the user clicks the arrow, a spinning circle animation does appear. In your case it may not be visible because the deserialization happens on the UI (main) thread. The solution here is to dispatch the time-consuming operations to a different thread since no controls can be updated while the ui thread is busy with something else.

Greetings,
Miroslav
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
0
Sushil
Top achievements
Rank 1
answered on 20 Sep 2010, 04:14 PM
Hi Miroslav,

In my application,
1. LoadOnDemand is true
2. IsLoadOnDemandEnabled has binding to view model property called 'HasChildren'.

e.g. Tree:

Root
   | - a
   | - b
   | - c

When i was loading children for Root, i check if 'b' has any children. Say 'b' has children, so i set b's 'hasChidlren' = true.
I double checked in 'ItemPrepared' event to see if 'b' has IsLoadOnDemandEnabled = true.

I still don't see the arrow for 'b'. ( Mostly)

Note: Some times when I stop for breakpoints and then hit continue, i see the arrow. The arrow visibility is random.

EDIT: Just noticed, If i collapse and expand the Root node, the arrow for 'b' becomes visible.

Any suggestions ?

Thanks.

0
Viktor Tsvetkov
Telerik team
answered on 23 Sep 2010, 04:58 PM
Hello Sushil,

Accept our apologize for the late reply. Could you please send me your sample project, because I am not able to reproduce your problem?

Kind regards,
Viktor Tsvetkov
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
Lauren Nickerson
Top achievements
Rank 1
Answers by
Sushil
Top achievements
Rank 1
Miroslav
Telerik team
Viktor Tsvetkov
Telerik team
Share this question
or