The options available for filtering an out-of-the-box (OOTB) list view web part on a managed metadata column are less than ideal. A client recently complained that filtering an OOTB list view with managed metadata fields doesn’t work well, because the filter mechanism shows the whole taxonomy and doesn’t eliminate options that would return no records.
Here’s an image of the edit control block (context menu) for the sorting/filter of an OOTB list view column. Here one can see the extrapolations of the term set, which has countries with rock band names underneath. This will allow me to choose “Creedence Clearwater Revival” for filtering, although no rows contain that metadata. Selecting “Creedance” will show zero records, confusing end-users worldwide.
OOTB Coolness: The one and only piece of functionality that I consider to be cool, is that the OOTB allows whole branches to be the filters. For example, clicking on USA will show matches for the descendants: “Creedance” and the “Grateful Dead”. That is, of course, if records do actually exist. Otherwise you’re looking at another zero records view, which will really confuse those expecting “Grateful Dead” records.
“Give Me Options”
I wish there was better news. I tried and tested many OOTB filter controls (enabled through the “Enterprise” feature):
- List Filter – was not able to filter on a managed metadata field.
- Choice Filter – could filter on managed metadata, but copying of all possible taxonomies is required.
- Text Form Filter – could filter on managed metadata, if the user knows exactly what they are looking for.
I could use the TaxonomyFieldControl from theMicrosoft.Sharepoint.Taxonomy namespace in a custom filter driver. This will present the user with a modal window to select the managed metadata. The value selected will then be used as the filter for the list view. Again, this still shows the entire term set in the taxonomy store rather than just displaying the items available for filtering.
“The Final Countdown”
Because my mind works this way, my solution to the problem would be to extend the OOTB Text Form Filter. I would utilize a client-side list web service pull to gather the possible filterable values based on managed metadata utilized within the library or list in question. Then I would use an autocomplete solution on the Text Form filter, so that users can start typing a managed metadata term, and the solution will offer suggestions. The best part about this solution is that it doesn’t involve managed code. That’s also the worst part…