Couple of weeks back, I have a scenario in which I have to filter List views based on two datetime columns (date departure and date return). After searching a bit, I have found an excellent article by Mark Rackley on nothingbutsharepoint.com. It has enough guidelines for me to achieve my task. So, here is what I did to achieve the solution:
- I have created a custom List called “My Report” using sharepoint portal
- Create a page in “Site Pages” Library called “Report View”.
- Edit Page in Designer: Open that “Report View” Page in Sharepoint Designer. This page could be found in designer > Left Navigation Tool Pane > Site Pages. Open the page in design mode.
- Adding Data View To Page: Click on Data View (ribbon > Insert Tab) and choose “My Report”.
- List Parameters: Select the List View, you then can view “List View Tools” in the ribbon, click on “Parameters”. This will cause a window to open.
- Creating List Parameters: Click on “New Parameter” twice. Give proper names to the parameters. In my case, I have given them Names as “DateTo” and “DateFrom”. From Parameter Source dropdown, select “Form”. Leave the other options, click OK.
- Creating List Filter using parameters: select List View, click on Filter (ribbon > List View Tools > Filter). You could see these fields i.e. Field Name, Comparision, Value. Now I have to view those items which are present inside that span that the user would select on the page, so my filter condition looks like {departure date > “DateFrom” and date return < “DateTo”}. So
- select “departure date” in field name column, select “greater than” in comparison, select “[DateFrom]” in Value, select “And” in And/Or column. select “date return” in field name column, select “less than” in comparison, select “[DateTo]” in Value.
- After setting the filter condition, save the page and close the designer.
- Go to the page using browser and open it in edit mode.
- Now Insert two date filter webparts (insert tab on the ribbon) on the page.
- In Webpart connection, select “Get Parameter From”, a dialog would appear.
- Choose “DateFrom” for one date picker and “DateTo” for second Date picker.
- Save the page
That’s it! You are done. Happy Exploring Sharepoint…
No comments:
Post a Comment