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

SelectedItems visible

1 Answer 51 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Mic
Top achievements
Rank 1
Mic asked on 15 May 2013, 08:02 AM
Hi. I use a TreeList with autogenerated columns and I create my TreeList control programmatically in Page_init event.
I need to show the "selected" Items stored in DB and for this I write my code in Pre_render event.
I have two critical questions:
1) is there a way to find an item by his PrimaryKey, without looping all items?
2) How to ensure visible my selectedItems? I try this but it fail (ie. my parent node remain close ... in my sample code I suppose to have only 2 level)
void MyCustomTreeList_PreRender(object sender, EventArgs e)    {
...
foreach (var item in this.Items) {
          string pkey = item.GetDataKeyValue(this.DataKeyNames[0]).ToString();
          if (SelectedKey.Contains(pkey))
          {
            item.Selected = true;
// How to ensure visible????
//            if (item.ParentItem != null)
//                item.ParentItem.Expanded = true;  
          }
...
        }

In my case I have no paging and I avoid the "Load on demand" scenario.
Some suggestion?
Thanks
Michela

1 Answer, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 17 May 2013, 10:47 AM
Hello Michela,

I have responded to you in the official support ticket. If you want you can share with the community the information provided.

All the best,
Angel Petrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
TreeList
Asked by
Mic
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question
or