Problems with OfficeServer:MetadataHierarchyData SourceControl

I like the managed meta data browsing in SharePoint 2010 that you get against a library.

My wish to to put something like this into a web part and this has worked with one problem.

So going back to managed meta data browsing by library.

This is fulfilled by MetadataNavTree.ascx

Taking a peek at this gives us an idea to create this tree in a web part.

So in my visual web part I have.

<SharePoint:SPHierarchyDataSourceControl runat="server"
  ID="MMTreeViewDataSource"
  IncludeDiscussionFolders="false"
  ShowListChildren="true"
        />
 <OfficeServer:MetadataHierarchyDataSourceControl runat="server"
  ID="MetadataTreeViewDataSource"
  SPHierarchyDataSourceId="MMTreeViewDataSource"
        />
 <SharePoint:SPRememberScroll runat="server" id="TreeViewRememberScroll" onscroll="javascript:_spRecordScrollPositions(this);"
  style="overflow-y: auto; overflow-x: hidden;">
  <SharePoint:SPTreeView runat="server"
   ID="MMTreeView"
   ShowLines="false"
   DataSourceID="MetadataTreeViewDataSource"

Other stuff....

OnTreeNodeDataBound="MMTreeView_TreeNodeDataBound"   >
  </SharePoint:SPTreeView>
 </SharePoint:SPRememberScroll> 

And in my code behind I have.

        protected void Page_Load(object sender, EventArgs e)
        {

            // When the page is loaded ensure that data source is bound to the correct list
            MMTreeViewDataSource.RootListId = ucpListID;
            MMTreeViewDataSource.RootWebId = ucpWebID;
            MMTreeView.ExpandDepth = ucpExpandDepth;
           
        }

This deploys as a web part and renders the managed meta data structure configured against the list (identified by RootListID) perfectly.  I can then override OnTreeNodeDataBound and make the links generated do something useful.

The odd problem is that unless the web part is deployed to a page in the RootWeb then it does not render.

This is because OfficeServer:MetadataHierarchyDataSourceControl will not return results when used in the above manner unless in the rootweb.  I tried using rootwebid and rootlistids from the same web as I deploy the webpart in but to no avail.

Any suggestions?

June 24th, 2013 8:40pm

Have you enabled metadata navigation in the other webs you're putting the webpart in?

Maybe this post will help: http://social.msdn.microsoft.com/Forums/sharepoint/en-US/bad86ce8-480b-4b73-af7f-50fb8955fb14/how-to-use-sphierarchydatasourcecontrol ?

Free Windows Admin Tool Kit Click here and download it now
June 24th, 2013 8:52pm

Yes this is enabled in the sub webs.

June 25th, 2013 11:25am

  • Hi Dave,

Greetings! Thanks for the post.

I have gone through the issue you described above and I do not see why you are facing the issue. To be able to troubleshoot and resolve your issue, I would request you to open a support ticket with Microsoft.

For more information about Microsoft Support please read the article http://support.microsoft.com/gp/proffaq/en-gb

================================================================================

Please remember to click 'Mark as Answer' on the post that helps you or click 'Unmark as Answer' if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

Thanks,

Bharat Rathod,

Microsoft Online Community Support

Free Windows Admin Tool Kit Click here and download it now
July 5th, 2013 3:17pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics