Hello everyone, in this post will discuss how to auto expand Metadata Navigation in SharePoint.
Metadata navigation can be very useful, it helps the user to create terms or tags which make life easy for user to search for any item.
Step 1: Create an app type list name it anything you want, I am giving list name: Metadata Navigation.
Step 2: Create metadata column call it Project type, if you don’t know how to create a column in SharePoint click here.
Step 3: Make sure you create some terms to serve the purpose if nothing is there under term sets (Project Type) , we won’t see anything after expanding it.
Step 4: Go to list setting, under general setting look for “Metadata navigation setting”, if you can’t find it.
Navigate to site setting under site actions, click on Manage site features and activate “Metadata Navigation and Filtering”
Now go back to the list setting and now you will see “Metadata navigation setting”, click on it and configure Navigation Hierarchies.
Select Project Type which we created and remove Folders which is by default gets added to selected Hierarchy fields.
Step 5: Navigate to list “Metadata Navigation” list
You will notice that terms are not expanded, it requires manual work.
Steps to auto expand metadata Navigation
Step 1: Press F12 from the browser and hover over your mouse on the sub level (Project Type) small triangle shape, which comes under the Metadata Navigation list
Step 2: Add content editor web part to the list page and link it to the below code
Create function expand()
_spBodyOnLoadFunctionNames array allows event handler to execute each function, which is used in thi array.
Finally, after putting the above script, refresh the page and metadata navigation is auto-expanded
I hope this article will help you guys, if you have any questions orsuggestion, let me know.
Thank you for visiting my blog. 🙂