0

Please let me know is there any way to filter list inside listview using restapi

Example: TestList Total item in list

And below is my custom search:(currently it is configured on Title field) enter image description here

Now after filter(Title=he) using restapi, it should show only those data in which Title contains 'he'

So Output will be: filtered result in list

I know it is possible using URL query string. but I dont want to show filter value on url(like /TestList/AllItems.aspx?FilterName=Title&FilterMultiValue=he)

So I want to build it using REST or JSOM or JQuery etc(any client side language which can be used in APP)

0

yes you can filter data of list using REST API ! check this link, a tutorial by Microsoft : Use OData query operations in SharePoint REST requests

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

  • when I add this answer your post have no much details... So i will answer it with a little more text – Nico Jul 11 '16 at 7:46
1

You can't use REST API to filter list view (for exemple your SPView: /TestList/AllItems.aspx)

To filter list view you should use CAML query (in the list settings, you could edit your views, and ADD filter to fields of your list). (ou can group, and do operation like count/sum/avarage ....). The user will not view this filter (so give to it a good title). This is the best way to filter a view, and it's simple. You can do this simply by using the SharePoint UI (List Settings => Views => Clic on your view To edit it => see Filter section) Or you can do this programmatically (by using the property Query) and Build your own SPQuery. (to build SPQuery there is a lot of doc/tuto on internet)

If this solution is not appropriate, you could use REST API yes. But you must create your own application page, Build a custom logic to render fields Data. And use REST API to get your data. Using REST API you can Filter data. But when you query the list you have to use GET protocol with specific parameter in URL. THis will help you to understand the logic to build filter with REST API : query operations in SharePoint REST But with this solution, you have to manage everything by hand (paginate query to avoid threshold list, the Quick edit, .....).

It depend on your need and if you have times.

  • Thanks for nice explanation. if i use SPQuery and update the view then, it is going to reflect for everyone. – Anil Pal Jul 11 '16 at 9:13
  • It depend on your SPView (you can have public SPView (for every one) or personal SPView (only for you)) In general it's public SPView – Nico Jul 11 '16 at 9:14
  • It is very difficult to filter lists using SPView in App(same app for all lists). – Anil Pal Jul 11 '16 at 9:56
  • Is there any other way without creating personal view and updating it. – Anil Pal Jul 11 '16 at 9:57
  • You should able to create custom view when you create your list in your apps. When you create your custom list, you could create custom SPView in the schema.xml of your list template – Nico Jul 11 '16 at 10:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.