how to test if a pagetree has a selected item?

Vote:
 

Dear all,

I might be going about this the wrong way but i want to programmatically test if a pageTree has a selected item. Is this possible?

I want to do this, because if none are selected I want to change the css class on the first item to highlight it.

Thanks for your help

#26659
Dec 15, 2008 15:44
Vote:
 

There is a property OpenPages that contains all expanded pages, maybe that could be a start.

 

#26689
Dec 16, 2008 11:08
Vote:
 

Create a method on you itemtemplate to a method that checks this:

if(pageTree.OpenPages.Contains(pageData.PageLink)

{

//your code

}

 -Kjetil Simensen

#26694
Dec 16, 2008 12:59
Vote:
 

Thanks Kjetil,

Perhaps I am missing something but the logic doesn't seem to work for me. That boolean expression always returns true.

It is on the first load of the page that I want to capture that no item is selected, but even then OpenPages contains currentpage, it looks pretty rudimentary but I am right in thinking if no page in the page tree has been selected the OpenPages.Count property is always 1?

Cheers,

Ian

#26701
Dec 16, 2008 15:33
Vote:
 

The container/rootfolder for all the pages in your tree is always in the OpenPages collection.

So you'll need to check if this has a count of 1, or if you have a reference to the container so that you have its page id, you can check if the OpenPages only contains the container/root folder then none are selected.

 PS: sorry for bad English, but i wrote it in a hurry :)

 - Kjetil simensen

#26705
Dec 16, 2008 16:27
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.