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

Parentrow problem

7 Answers 108 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
allyk
Top achievements
Rank 1
allyk asked on 21 Jun 2011, 01:55 PM
Hi,
 I generate my row like this:

Telerik.Windows.Controls.TreeListView.

 

TreeListViewRow row = (Telerik.Windows.Controls.TreeListView.TreeListViewRow)radTreeListView1.ItemContainerGenerator.ContainerFromItem(radTreeListView1.SelectedItem);

If I see parent row on the screen, I can reach row.ParentRow but if I don't see parent row on the screen
row.ParentRow is null.

How can I handle this?
Thanks.

 

7 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 21 Jun 2011, 02:45 PM
Hi allyk,

That would be the expected behavior due to the fact that the virtualization of the RadTreeListView is turned on by default. This means that only the visible visual elements are created and on scrolling they are recycled and reused. Generally, the recommended way is to work directly with the underlying data item (by Items collection for example). 
May you share what is the scenario that you want to accomplish ? Why do you need to work with the rows, instead of the items ? 
 

Kind regards,
Maya
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
allyk
Top achievements
Rank 1
answered on 21 Jun 2011, 03:30 PM
Hi,
Thank you for your reply.
I am not sure how I can take the parent item from underlying data.
I can reach child items  like this (MyClass)treelistView1.SelectedItem).Items, But how can I reach parent Item? Should I  have a reference back to its parent class?

Thanks.
0
Maya
Telerik team
answered on 22 Jun 2011, 08:56 AM
Hi allyk,

Basically, you may use the connection between the parent item and its children. May you provide a bit more details what is the implementation of the two business objects ? Do you have an exposed property connecting them ? 
 

Greetings,
Maya
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
allyk
Top achievements
Rank 1
answered on 22 Jun 2011, 04:34 PM

Hi,
My implementation is similar sample classes below.

public class Level0_0
{
        public string Level0{ get; set; }
        public ObservableCollection<Level1> Items { get; set; }
 }

public class Level0_1
{
        public string Level1{ get; set; }
        public ObservableCollection<Level2> Items { get; set; }
        public Level0 ParentItem { get; set; }
     
}

public class Level0_2
{
        public string Level2{ get; set; }
        public ObservableCollection<Level3> Items { get; set; }
        public Level1 ParentItem { get; set; }
     
}

 

My problem is Level0_2 is shared object. For example Level1_1 object also have Level0_2 object. So I overrite ParentItem. 

I have to take the root element of the selected item. Is there any way to turn off virtualization?

Thanks

0
Maya
Telerik team
answered on 27 Jun 2011, 02:50 PM
Hi allyk,

Based on the code-snippet provided, I get the impression that you may use the ParentItem property of the business object. Am I right or am I missing something ?
Considering turning off the virtualization, you may set the EnableColumnVirtualization/ EnableRowVirtualization properties of the RadGridView to false. However, if you handle a lot of data, this might lead to some performance issues.
 

Greetings,
Maya
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
allyk
Top achievements
Rank 1
answered on 28 Jun 2011, 01:12 PM
Hi,
Yes, I can use ParentItem. But my problem occurs when I used shared objects as I mentioned. For example I have shared static object Level0_2 then it has two parents:Level0_0 and Level1_0. When I select the Level0_2 item I can't use ParentItem property. Because of this I want to use ParentRow.
Level0_0
     Level0_1
     Level0_2
Level1_0
     Level1_1
     Level0_2
0
Maya
Telerik team
answered on 30 Jun 2011, 10:17 AM
Hello Allyk,

The only way for getting the parent item to handle it at data level. As the structure of the TreeListView is a flat one, no actual hierarchy at UI level is created. Thus, if you want to find the parent item from a child one, you need to have a single parent and find it through the corresponding property. 

All the best,
Maya
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
TreeListView
Asked by
allyk
Top achievements
Rank 1
Answers by
Maya
Telerik team
allyk
Top achievements
Rank 1
Share this question
or