In this article we will be seeing how to configure key filters in SharePoint 2010 using C#.
Key Filters appear just below the navigation hierarchy. Refer this Article to configure navigation hierarchy. Key Filters operate similar to the navigation hierarchy. They are used to filter the view of lists / document libraries.
The following fields are available for key filter fields are
Managed Metadata Field
Person or Group Field
Date and time field
I have a list and I am having the following items.
I am going to add the fields to the Key Filter Field using #
Open Visual Studio 2010.
Create Console application.
Replace the code with the following.
static void Main(string args)
using (SPSite site = new SPSite("http://serverName:1111/"))
using (SPWeb web = site.RootWeb)
MetadataNavigationSettings listNavSettings =MetadataNavigationSettings.GetMetadataNavigationSettings(list ;
MetadataNavigationKeyFilter mdnKeyFilter=new MetadataNavigationKeyFilter(field);
Go to the List => List Settings =>General Settings =>Metadata navigation settings => Configure navigation hierarchies.
I have added "Country" field to the key filter field as shown in the following.
Click on Ok.
You could see the Key Filters in the left hand pane of the user interface.
Select some value from the key field and click on "Apply". You could see the view has been changed for the list based on the key field value.