Any idea to hide non-site items in the Sharepoint 2010 tree view control? Or the only chance is to develop our own control and integrate it on the master page?

there's this link but it doesn't seems so quite simple.


Updated: Actually it works fine in masterpages, but only in blank sites. anyone knows why?

  • what exactly do you want to display/hide.. the article looks simple enough. Jan 26 '12 at 14:51
  • hide all site content in tree view control, leaving only the inherent Sites and Subsites below it.
    – fallout
    Jan 26 '12 at 15:40
  • check my answer below Jan 26 '12 at 16:14

If you want to just show Sites and Subsites below it, you can setup the Data Source like this:

 <SharePoint:SPHierarchyDataSourceControl runat="server" ID="TreeViewDataSource"  
        IncludeDiscussionFolders="false" ShowListChildren="false" ShowDocLibChildren="false"
        ShowFolderChildren="false" RootContextObject="Web" />

And use above data source with the treeview as shown below:

  <SharePoint:SPTreeView runat="server" ID="WebTreeView" ShowLines="false" DataSourceID="TreeViewDataSource"
        ExpandDepth="0" SelectedNodeStyle-CssClass="ms-tvselected" NodeStyle-CssClass="ms-navitem"
        NodeStyle-HorizontalPadding="2" SkipLinkText="" NodeIndent="12" ExpandImageUrl="/_layouts/images/MDNCollapsed.png"
        ExpandImageUrlRtl="/_layouts/images/tvclosedrtl.png" CollapseImageUrl="/_layouts/images/MDNExpanded.png"
        CollapseImageUrlRtl="/_layouts/images/tvopenrtl.png" NoExpandImageUrl="/_layouts/images/tvblank.gif"


I tested above in custom application page and it apperas as below:

enter image description here

  • It works, for real. thanks. But actually I was trying to get the same result throw the masterpage and that is what I'm not getting to.
    – fallout
    Jan 30 '12 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.