I am trying to display 5 levels of document library in a tree view to show all the files within all folders and sub folders. How can I achieve this task?

  • Is your folder quantity fixed or folders will be added/deleted anytime? – harshal gite Oct 31 '18 at 18:12

You can use server side object model for this.

There is very good example of your problem:


  • I am aware of this URL and it is not a feasible solution for my requirement as I need to host my library in Office 365(it contains some of the namespaces are not allowed in Cloud). – Ram May 20 '14 at 11:22
  • I was not aware you are using Sharepoint online. You can use client object model for this. – Aanchal May 20 '14 at 11:28
  • Also check: community.office365.com/en-us/f/154/t/20212.aspx – Aanchal May 20 '14 at 11:31
  • The above URL is also redirecting to the codeproject URL which you have mentioned. I am trying to display this in a web part. – Ram May 20 '14 at 11:38
  • So, In sahrepoint online you need to use Sharepoint CSOM and iterate through all the documents and folders and bind that to your treeview. There is no out of the box solution for this. – Aanchal May 20 '14 at 11:59

Sometime back I created a tree view collapsible menu for SharePoint Online. Following is the URL


However try to use PnP JavaScript embed instead on directly modifying the masterpage.


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.