Tell me how to programmatically (REST API, JQuery, SPServices) make your transition to another view list/library? I already have the code for get, i.e. In the select view I have already added, but how to do the transition to views, preferably for SharePoint 2010 and 2013, all thanks for the replies. enter image description here

1 Answer 1


The views can be created for a list with manual steps by going through the list settings. The same can be implemented programmatically using several methods. In this article, you will learn how it can be implemented using JavaScript Object Model.

For example, I have created a list called “Test” with two custom columns, Column1 and Column2. By default when you try opening a list in SharePoint, the default view called “All Items” will be rendered. This view will show you three columns. They are Title, Column1 and Column2. enter image description here

The following flow will show you the implementation:

  1. Load the SP.js files and get the context of site.
  2. Get all the views for a specific list present on the site.

    var listCollection = web.get_lists();
    list = listCollection.getByTitle("Test");
    viewCollection = list.get_views();

  3. Create a custom view ViewCreationInformation method. Set view title and the fields to be shown on the view using the following code:

var createView = new SP.ViewCreationInformation();
var viewFields = ["Column1","Column2"];

  1. Then build your query to retrieve the values for the view. This step can be an optional one: enter image description here

  2. The view can be limited with custom row limit:


  1. The view can be still customized with view types. The applicable types are html, grid, etc. The following code shows you how to set the type:


  1. Then add the view to the collection and execute the query:

viewContext.executeQueryAsync(ViewCreated, onFail);

  1. After execution of the above approach, go to List tab and you can see the new view, “Grid View,” created. Click on the new view to see the list with necessary filters set. The following snapshot helps you to change the view. enter image description here

The following table shows you different types of field types with values: 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.