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

[Solved] Knowing which child node is checked

1 Answer 80 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
toiby
Top achievements
Rank 1
toiby asked on 20 Apr 2009, 12:56 PM

I am using the radTreeViewControl I added the items with the property ItemsSource, according the an example I saw in the forums.
I want to bring data to my application according the checked items.
I'm not succeeding to know which child node is checked.
While debuging, the debuger shows that the parent is checked, and doesn't show the child,(In the UI the child node is checked).
So how could I know which child is checked?


I create the class
public class DataItem

 

{

 

public MyPath Key { get; set; }

 

 

public string Name { get; set; }

 

 

public List<DataItem> Items { get; set; }

 

 

public DataItem()

 

{

 

this.Items = new List<DataItem>();

 

}

 

}

added the items

 

 

void LoadRootNodes(MyKey[] keys, MyPath path)

 

{

 

foreach (MyKey key in keys)

 

{

 

MyPath tempPath = path.GetChildLevel(key);

 

 

foreach (W6TreeNodeConfigSection node in settings.TreeNodes)

 

{

 

if (node.W6Key == key.Key.ToString())

 

{

 

if (node.View.Equals(true) && settings.ViewAll.Equals(true))

 

{

Items.Add(

new DataItem() { Key = key, Name = key.Name });

 

 

if (m_navigationTree.GetChildrenPaths(path).Length > 0)

 

{

LoadChildren(tempPath, Items[Items.Count - 1]);

}

 

break;

 

}

}

}

}

}

 

private void LoadChildren(MyPath path, DataItem item)

 

{

 

MyKey[] keys;

 

keys = m_navigationTree.GetChildrenKeys(path);

 

Array.Sort(keys);

 

 

foreach (MyKeykey in keys)

 

{

item.Items.Add(

new DataItem() { Key = key, Name = key.Name });

 

 

if (m_navigationTree.GetChildrenPaths(path).Length > 0)

 

{

 

MyPath tempPath = path.GetChildLevel(key);

 

LoadChildren(tempPath, items[Items.Count - 1]);

}

 

}

}

 


 

 

 

List<DataItem> items;

 

 

public List<DataItem> Items

 

{

 

get { return items; }

 

 

set { items = value; }

 

}

 

 

telerikTreeView.IsTriStateMode =

true;

 

telerikTreeView.SelectionMode =

SelectionMode.Multiple;

 

telerikTreeView.ItemsSource = Items;

telerikTreeView.ItemsOptionListType =

OptionListType.CheckList;

 

telerikTreeView.IsOptionElementsEnabled =

true;

Thanks
Toiby

 

1 Answer, 1 is accepted

Sort by
0
Bobi
Telerik team
answered on 21 Apr 2009, 10:42 AM
Hi Toiby,

You can find attached a sample project that demonstrates how to get the checked nodes in a RadTreeView. If you still face any difficulties in implementing this functionality in your code please zip your project and send it to us so that we can take a look.

I hope this helps.

Sincerely yours,
Boryana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
TreeView
Asked by
toiby
Top achievements
Rank 1
Answers by
Bobi
Telerik team
Share this question
or