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
I have a list and I am having the following items. I am going to add the fields to the Key Filter Field using # Steps Involved:
namespace ConfigureKeyFilter { class Program { static void Main(string[] args) { using (SPSite site = new SPSite("http://serverName:1111/")) { using (SPWeb web = site.RootWeb) { SPList list=web.Lists.TryGetList("cl"); SPField field=list.Fields["Country"]; MetadataNavigationSettings listNavSettings = MetadataNavigationSettings.GetMetadataNavigationSettings(list ; MetadataNavigationKeyFilter mdnKeyFilter=new MetadataNavigationKeyFilter (field); listNavSettings.AddConfiguredKeyFilter(mdnKeyFilter); MetadataNavigationSettings.SetMetadataNavigationSettings(list, listNavSettings, true); } } } } }
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.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: