Everyone know how to modify view in SharePoint document list or any custom list. I.e. Enter the list -> click modify view -> and filter based on name etc.

However, I am trying to achieve this in a app part in SharePoint Online.

It would be nice, if anyone can give me an idea how I can apply filter [modify view] programatically using JavaScript in SharePoint online app part.

  • @maleman: Not exactly, I do not want to change different view lready present. Rather, I need to set/apply new view programatically using javascript from client web part. we do this on the page level Enter the list -> click modify view -> and filter based on name etc. I want to achieve the same but programatically. Thank you
    – Rakesh
    Jun 14 '17 at 10:51

If I understand your question correctly you are trying to allow the user to change to a different view that is already created for a specific list. One approach may be to use the view's id and attach it to the URL as a parameter (i.e. ?viewid=[the view's id number]). You can see the id when displaying the list using the view while using the OTB SharePoint list display.

Another approach would be to use the REST API to read all of the views available for the list and present them to the user.

Once you have their selection navigate to the list's URL with the appropriate view parameter.

See SharePoint REST for information on the REST API.

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.