How to set SharePoint list view 'Item Limit' with the option “Display items in batches of the specified size.” programmatically

sharepoint.stackexchange https://sharepoint.stackexchange.com/questions/175071

Pregunta

How to set SharePoint List View 'Item Limit' programmatically with the option 'Display items in batches of the specified size.' selected.

By default, 'Limit the total number of items returned to the specified amount.' option is selected. I want to change it to 'Display items in batches of the specified size.'

enter image description here

¿Fue útil?

Solución

Please try below mentioned code

    using System.Net;
    using Microsoft.SharePoint.Client;

    namespace ClientObjectModelConsoleApplication
    {
      class Program
      {
        static void Main(string[] args)
        {
          ClientContext clientContext = new ClientContext("http://hercules");
          clientContext.Credentials = new NetworkCredential("Administrator", "12345");
          string listName = "My Custom List", viewName = "All Items";



          // true is "Display items in batches of the specified size"
          // false is "Limit the total number of items returned to the specified amount"
          bool paged = true;      



          List list = clientContext.Web.Lists.GetByTitle(listName);
          View view = list.Views.GetByTitle(viewName);
          view.Paged = paged;
          view.Update();
          clientContext.ExecuteQuery();
        }
      }
    }
Licenciado bajo: CC-BY-SA con atribución
scroll top