sireesha kns
sireesha kns

Reputation: 11

Passing a date as query string parameter to sharepoint list view webpart

I have list view web part which I would like to filter by the "Created" field by setting the filter parameter value from query string. I tried passing various values in different ways:

e.g: .../../samplepage.aspx?startDate=2016-11-01T18%3a55%3a28Z

So far had no luck.

Upvotes: 0

Views: 1588

Answers (2)

Thriggle
Thriggle

Reputation: 7059

If this is an out-of-the-box list view web part in SharePoint 2010, you can use two query string parameters to automatically apply filtering to the web part.

&FilterField1=[InternalName]&FilterValue1=[YEAR%2DMONTH%2DDATE]

For example, if you wanted to only show results where the Created date is equal to January 1st, 2014, you could use the following query string parameters.

&FilterField1=Created&FilterValue1=2014%2D01%2D15

If there are multiple list view web parts on the page and you only want to filter on one of them, you can include a View parameter in the query string indicating the GUID of the web part to which you want the filter to apply.

For example:

View={354D9BAC-E26A-4FDB-A9BE-FEA626FD4733}&FilterField1=Created&FilterValue1=2014%2D01%2D15

Note that if you want to apply multiple filters simultaneously, you need only to increment the numerical suffix on FilterField1 and FilterValue1 for each new field/value pair on which you want to filter.

Upvotes: 0

JJFlash42
JJFlash42

Reputation: 131

You can pass the seconds since epoch which on the client side you obtain by passing the date to the Date constructor and calling getTime, e.g:

new Date("2016-11-01T18:55:28Z").getTime()

then convert it to the format you need on the server side for sorting.

Upvotes: 1

Related Questions