Using filtering in the DataviewWebPart

As a result of the great interaction of the SharePoint community on twitter, I created this blog entry. 140 characters are definitely not enough to ask my questions, and Stump The panel doesn’t allow screenshot (I think). The content I provide is fictive, but the setup is real J. Please note, that the screenshots are from the test environment, and I blurred some thing due to confidentiality.

My current setup. We’re working with MOSS 2007. There is a site collection with a root site, let’s call it rootsite. Under the rootsite, there are several subsites, let’s call them subsite1, subsite2, ….
The members of subsites will only have access to their subsite. We can say that the subsite=registrant (so metadata hereunder)
In the root site I have a list. Let’s cal this list registrations. This list has several columns (metadata) Registration date,
Registrant, visible4all, material, unit,…

  • Registration deadline (date)
  • Registrant (lookup to a list called registrants)
  • visible4all (Yes/no)
  • material (single line of text)
  • unit (single line of text)
  • ,…

What would I like to have.

On a subsite, I would like to have a page with a view on the registrations list in the rootsite. The filter should be : Show items where (registrant=xxx or visible4all=Yes)
I created a dataviewwebpart to get that data. This will give me a list with all the registrations for that registrant. (I added the filter in the DVWP in the common dataview tasks) In this list I would like to use some extra filtering. For instance, I would like to filter on material, and would like to be able to filter even more , for instance on unit. (so the existing filter of the DVWP would be filtered on material, and then on that filtered data I would like to filter a unit) When I want to use the filter possibilities in the DVWP I click on DV properties (in SharePoint designer) and select Filter

This gives me a lousy implementation of the filter possibilities (click on filter, then select a filter). But entries appear multiple times in the dropdown list of that filter (for instance, when material wood is used in multiple entries in that list, it would appear multiple times in the drop down box). This results in a highly user-unfriendly way to filter data.

I installed the instantfilter from Jaap Vossers. I thought this would be a great solution, but the users say they don’t know the filter values by heart, hence they can’t use a system like this. They would really like to pick something from a dropdown box or something.

So, the actual question:

What possibilities do I have to setup a decent filter in the DVWP? A decent filter system would be something that you have by default on a document library or a list. Other solutions are also welcome. (must say, I rather new to XSLT and Jquery, but I’m a good searcher and am aware of the CTRL-C/CTRL-V keys of my keyboard J, and until now, I most questions I received coud be solved with other things than Jquery and or “copy-pastable Jquery” stuff ….

 

Suggestions are welcome in the comments, but if you need some more rich text, you can email me at . When you email me, I will do my outmost best to make an overview and create a blog post with the answers.

As a result of the great interaction of the SharePoint community on twitter, I created this blog entry. 140 characters are definitely not enough to ask my questions, and Stump The panel doesn’t allow screenshot (I think). The content I provide is fictive, but the setup is real J. Please note, that the screenshots are from the test environment, and I blurred some thing due to confidentiality.

My current setup. We’re working with MOSS 2007. There is a site collection with a root site, let’s call it rootsite. Under the rootsite, there are several subsites, let’s call them subsite1, subsite2, ….
The members of subsites will only have access to their subsite. We can say that the subsite=registrant (so metadata hereunder)
In the root site I have a list. Let’s cal this list registrations. This list has several columns (metadata) Registration date,
Registrant, visible4all, material, unit,…

  • Registration deadline (date)
  • Registrant (lookup to a list called registrants)
  • visible4all (Yes/no)
  • material (single line of text)
  • unit (single line of text)
  • ,…

What would I like to have.

On a subsite, I would like to have a page with a view on the registrations list in the rootsite. The filter should be : Show items where (registrant=xxx or visible4all=Yes)
I created a dataviewwebpart to get that data. This will give me a list with all the registrations for that registrant. (I added the filter in the DVWP in the common dataview tasks) In this list I would like to use some extra filtering. For instance, I would like to filter on material, and would like to be able to filter even more , for instance on unit. (so the existing filter of the DVWP would be filtered on material, and then on that filtered data I would like to filter a unit) When I want to use the filter possibilities in the DVWP I click on DV properties (in SharePoint designer) and select Filter

This gives me a lousy implementation of the filter possibilities (click on filter, then select a filter). But entries appear multiple times in the dropdown list of that filter (for instance, when material wood is used in multiple entries in that list, it would appear multiple times in the drop down box). This results in a highly user-unfriendly way to filter data.

I installed the instantfilter from Jaap Vossers. I thought this would be a great solution, but the users say they don’t know the filter values by heart, hence they can’t use a system like this. They would really like to pick something from a dropdown box or something.

So, the actual question:

What possibilities do I have to setup a decent filter in the DVWP? A decent filter system would be something that you have by default on a document library or a list. Other solutions are also welcome. (must say, I rather new to XSLT and Jquery, but I’m a good searcher and am awarae of the CTRL-C/CTRL-V keys of my keyboard J, and until now, I most questions I received coud be solved with other things than Jquery and or “copy-pastable Jquery” stuff ….

 

Suggestions are welcome in the comments, but if you need some more rich text, you can email me at . When you email me, I will do my outmost best to make an overview and create a blog post with the answers.

About Patrick Sledz

Patrick works as a consultant. He assists organizations to deliver SharePoint business value and create the awareness in these organizations that only a strong technical team is not sufficient to deliver this added value.
Tagged , . Bookmark the permalink.
  • http://www.iwkid.com Raymond

    I would use a 2nd DVWP on the page that generates the filter dropdowns. Then, I would make that DVWP post back to the same page with querystring values: ?regDeadline=01012011&reg=person&….
    Then in the actual DVWP, I would configure it to filter using querystring parameters.

    Distinct Values in a DVWP: http://sharepoint.strident.co.uk/archives/572
    Date filtering: http://blogs.msdn.com/b/sharepointdesigner/archive/2008/02/25/filtering-and-formatting-with-date-values.aspx
    Query Strings + DVWP: http://www.sharepoint911.com/blogs/laura/Lists/Posts/Post.aspx?ID=81

    -Raymond

  • Pingback: Tweets that mention Using filtering in the DataviewWebPart - Office and Business Productivity -- Topsy.com()

  • http://www.modery.net Rene

    I might have a solution for you. I did something like that (at least the way I understand you right now, it’s similar) just a few days ago, but haven’t finished my blog posting for it yet. Once I’ve published it, I’ll let you know! Hopefully sometime over the weekend
    And just FYI: My solution uses jQuery ;)

  • http://sympmarc.com Marc D Anderson

    Patrick:

    Sorry for the delay in getting back to you on this. What I would do is take a step back and think about the use cases some more and then build the solution that will really work best for the users to solve those particular problems. IMO, the top-of-column filtering stuff usually makes less sense to users when they have specific goals than when they just “might like to filter sometime”.

    All that said, how would I build it based on what I know? I’d ditch the SPD-generated filtering and write my own XSL in the DVWP to add some dropdowns at the top of the page only for the columns that people are really going to filter on. For instance the date/time column I see in your screenshot may not be one which is useful to filter on, where Material clearly is. To do this, you’ll have to get your hands dirty with the XSL, but you’ll probably be providing your users with a better solution. You can do the dropdowns and a ‘Submit’ or ‘Go’ button at the top of the DVWP in the same DVWP (you already have all the items) or you can create separate DVWP(s) for them.

    This blog post of mine may be of help:
    http://sympmarc.com/2008/01/03/firing-an-event-when-a-user-selects-a-value-from-a-data-view-web-part-dropdown/

    Finally, since it sounds like you will be using this DVWP on multiple sites based on their URLs, I’d store the XSL in a central place (I usually use a Document Library in the root site if it’s WSS or the /Style Library/XSL Style Sheets folder if it’s MOSS) and use xsl:import to pull it into each DVWP.

    Hope this helps.

    M.

  • Npi_tweet

    Best to adjust the links on the registration list using jquery to include the filters you want in the URL. Include your field name and include the values in the URL like this.
    &FilterField1=SupplierID&FilterValue1=82&

  • http://www.modery.net Rene
  • http://www.modery.net Rene

    I just realised that my solution doesn’t work with a DVWP. While looking for a way to make it work, I discovered the following which can help you in your case:
    http://www.petestilgoe.com/2010/08/dvwp-how-to-remove-duplicate-entries-in-filter-dropdown-list/