For demonstration purpose I’ll use the default “documents” document library and added 2 custom columns department and language respectively. Department column is a lookup column based on custom list called “Departments”. Departments custom list contains all departments. The second column language is a choice column with English, Spanish, and French values
Implementing the filter criteria Interface using content editor webpart
HTML snippet below is added to content editor webpart, contains 2 select controls one for departments and the other for author (depending on your requirements this might vary for your scenario). I also have a language field which will display dropdown, radio button or checkbox depending on how the choice column is configured on server, finally there is a button control, when user clicks on it, will implement document library filtering using the criteria specified.
Preview of Filter Page
Binding HTML Select in content editor webpart to a sharepoint list
The filter criteria interface implemented with content editor webpart contains 2 dropdown list controls, department and author, If you take a close look at the HTML snippet you’ll notice there are no option elements defined inside the select tag, this is because we want to dynamically bind it to sharepoint list (‘departments’, ‘userinfo’ respectively).
Figure below show HTML select control in content editor webpart bound to a sharepoint list.
Displaying the Language choice column in Filter Criteria View
There is two of things we need find before implementing the filter
- view GUID for the “documents” list view.
- Internal field names for all columns used in filter criteria view
To find out the view GUID and internal field names you can click on the column header dropdown and select one of the values.
Copy the GUID and Internal Field Name from the header, also notice the querystring format, we are going to build the querystring similar to it from our filter method so we can leverage out of the box document library filtering
This approach is only a workaround, if out of the box document filtering doesn’t satisfy your requirements and you have constraints on writing assembly code this approach might come handy. You should evaluate all options, custom filter webpart, etc before deciding the correct approach.