0

I am developing SharePoint hosted app. In that I have to use SPTreeView to display root site content in the Tree view form. For the data source I have to use SPHierarchyDataSourceControl. But I don't know how to use this in my SharePoint hosted app.
My Questions are:

  1. How can I set the RootWebId of the SPHierarchyDataSourceControl in javascript?
  2. How can I use these controls in my app?
  3. Is there any other ways(like using JQuery or other controls) to achieve this?
1

SPTreeView is a server side control. You can render it as the declarative attributes are evaluated during the standard asp.net life cycle on server side. This will resolve the data from the datasource. But once rendered there is no way to replace the data without a postback (maybe inside an update panel) and server side code. If rendering is enough, you might be able to use some of the information from here: SharePoint 2010 TreeView example

But unfortunately SharePoint hostet apps does not allow any form of custom server code as part of the app.

One alternative might be to use a client side tree like JSTree and get the data via JSOM calls like in this C# Example .Net Managed Client Object Model: Fetch All Webs, Libraries, Items. Or switch to self/Azure hosted Apps and use server side code.

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.