Today I had a requirenment to filter couple of webparts on a page by item Created Year. This means the paage will gets filtered accroding to a specific year (Year Selected).
To acomplished this I used a Javascript drop-down list which contains year values of last 5 years, from the current year and of next 5 years including the current year. This drop-down list was populated on page load.
Next added a "Go" button to filter the page.
Go button - Go button when clicked will actually redirect to the same webpart page but will also appended the selected year (from drop-down) as paramenter to the Querystring.
So now once we had our desired year in the url, all we needed was a URL QueryString webpart on the page and a Year column in webparts which QueryString webpart will filter on.
So, add a URL querystring filter webpart to your Page with Year as the Querystring parameter.
Year column - Next add a new calculated column "Year" in your Library. The column will only display Year (from Created column) and will get populated when the item or file is added to the library.
Once added, add this column Year to your Listview webpart on the Page. Dont forget to create connections between the URL Querystring and the WebParts to Filter. Also, make sure that the Year in URL maches the Year column name in webpart.
Test - Select the current year from drop-down and click Go. The Go button will redirect to self and along with a Year=2011 appened as a QueryString. The Url redirect webpart from here will extract the Year column value and Filer the connected webparts with the Year column.
Now, if your trying to do the same thing in SharePoint 2010 then you can use the HTML Form WebPart to filter the webparts.
No comments:
Post a Comment