Wednesday, April 17, 2013

Sharepoint 2010 List filtering by date range

1.    Add new item for Task list
2.    Go to Site Actions >> Edit Page
3.    Add web part Date Filter
4.    Edit Web part
5.    In the options pane that appears, change the Filter name to 'Start Date', and change the default value to 'offset from today 7 days: Before today'. Then click ok.
6.    Underneath that, add another date filter and change its filter name to 'End date', and change the default value to 'offset from today: 0 days: After today'. Then click ok.
7.    Now save the page in your browser, then open the page up in SharePoint designer (SPD) - in design view.
8.    Edit page in Advanced Mode

9. Once opened in SPD, click on the list web part to select it, then in the ribbon click on the list view tools > options > parameters icon.


10.  Add two new parameters, one called 'startdate'. Leave the parameter sources and default values as default.
11.  Add two new parameters,  called 'Enddate’. Leave the parameter sources and default values as default.
12.  Click OK
13.  Click on the start date filter and click add connection
14.  In the dialog that pops up change the dropdown value to 'Send filter values to', click next.
15.  Ensure that 'connect to a web part on this page' is selected in the next dialog and click next.
16.  Change the target action in the next dialog to 'Get parameters from' and click next.
17.  In the next dialog, select 'Start Date' from the first box, and 'Startdate' from the second box and click next. Then click finish.
18.  Click Finish
19.  Click on the End date filter and click add connection
20.  In the dialog that pops up change the dropdown value to 'Send filter values to', click next.
21.  Ensure that 'connect to a web part on this page' is selected in the next dialog and click next.
22.  Change the target action in the next dialog to 'Get parameters from' and click next.
23.  In the next dialog, select 'End Date' from the first box, and 'Enddate' from the second box and click next. Then click finish.
24.  Click Finish
25.  Now we have our date filters feeding the list with its values but we still have to set up the filter on the list. Click the list web part to select it, then in the ribbon click on the list view tools > options > filters icon.
26.  The filter criteria box wills popup. First add a rule 'Start Date > Greater than or equal to > [Startdate]'.
27.  Click to “Click here to …”
28.  Then add another clause 'Start Date > Less than or equal to > [Enddate]'. Click ok.
29.  Now save the page and open it back up in your browser. It will, by default, show all tasks Start Date in the last seven days thanks to the default setting of the start date filter. Changing these filters will filter the list according to the date ranges set.
30. You can write your caml query in sharepoint designer

0 comments:

Post a Comment