SharePoint Web Part Visibility Filter Web Part
I was recently contacted through my blog with a question on how to dynamically hide/show a web part on a web part page based on a user’s selection of a UI element on the page. While there’s several methods you could employ to perform this task, one nice, neat implementation that you could leverage is posted up on our CodePlex site called the SharePoint Web Part Visibility Filter Web Part.
Through the implementation of this web part, you have the ability to accomplish the following scenario:
You have a standard SharePoint list containing a listing of items that offer selection options and a ‘Item Detail’ part, which happens to be an implementation of the Visibility Filter Part, that will show detail information based on the user selection from the list above it.
In the screenshot below, upon making a different selection from the list of items, a new details web part is now displayed showing details for the selected item.
Now this implementation is built upon concepts that have been around SharePoint for quite some time, like connected web parts, however, this is a decent implementation that addresses the requirement for being able to dynamically hide and show web parts based on some dynamic criteria.
A few caveats to keep in mind (taken from the notes on the project’s CodePlex page):
The web part needs to render itself before the web part(s) that may be affected by it (hidden or unhidden), so you need to place it in a web part zone above the potentially affected web parts. Web parts are rendered in order of their zone indexes, and then their index within each zone. If a web part is rendered before the Visibility Filter Web Part that affects it, its visibility will not appear to have changed because it was already rendered. In other words, your Visibility Filter web parts should probably be placed at the top of your page, before all other web parts.
You may need to include multiple instances of this web part on a page to selectively hide/unhide web parts.