I have a simple document library web part added to my SharePoint aspx page.

I'm wondering if I can change the View inside a Document Library WebPart from JavaScript dynamically?

For Example:


Here Test is my current View

And the Document Library is having default All Documents View. I want that the document library web part should change the View from All Documents to Test View.

Is something like this possible using JavaScript?

  • Please explain which can of page and add an image if you can. Jul 19, 2017 at 10:06
  • The given edit for the question is what one would expect the requirement to be. However, the initial question could be altered to different requirements, which is why I'd hope the OP @kolek to confirm whether the question is now addressing the original requirement.
    – moe
    Jul 19, 2017 at 10:14
  • yes it still meets the requirements
    – kolek
    Jul 19, 2017 at 10:16
  • Do you want to change the view to Test permanently? Or it should be changed according to query string? Jul 19, 2017 at 11:16
  • It should change according to query string
    – kolek
    Jul 19, 2017 at 11:35

1 Answer 1


ListView WebPart's added on a page, its source view cannnot be changed dynamically using client side code ( JavaScript ).

However, here are work arounds:

Method #1

  1. Insert an IFrame on your page and set the source to View page URL with passing URL parameter IsDlg=1. Example: AllItems.aspx?IsDlg=1

  2. Use JavaScript to update IFrame source URL

Method # 2

You can pass filter parameters to your page.


You can also extend it to pass more paraters like this: YourPage.aspx?FilterField1=Title&FilterValue1=SomeValue&FilterField2=OtherField&FilterValue2=OtherValue

So, using JavaScript you need to reload page with required URL parameters.

The downside of this solution is that filter applies to all ListView WebParts on that page. enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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