title: Presetting kendo DataSource PageSize to "All"
body: <p>Whenever a user changes the pagination on a grid, I save the setting in localStorage and retrieve it to set it back whenever the user navigates again to the page. To retrieve it I am using the pageSize property of the dataSource where I pass an IIF like so:</p>
  
  <pre><code>    pageSize: function () {
          var pageSize = 10;
          if (window.localStorage) {
              var userPreferencePageSize = localStorage.getItem("somegridPageSize");
              if (userPreferencePageSize === parseInt(userPreferencePageSize)) {
                  userPreferencePageSize = parseInt(userPreferencePageSize);
              }
  
              if (!isNaN(userPreferencePageSize)) {
                  pageSize = userPreferencePageSize;
              }
          }
          return pageSize;
      }()
  </code></pre>
  
  <p>This worked well but a requirement appeared for the user to be able to set the pageSize to "All". Kendo handles "All" in the Grid so I thought this will let me set the dataSource pageSize to the string "All" (pageSize="All") as well. When I do it however the grid starts displaying NaN of X records and displays an empty grid. So the question is.. how do I preset the pageSize of the dataSource to just "All"?</p>
  
  <p>NOTE: An alternative is to just fetch the grid maximum total count and then replace the number displayed in the dropdown with jquery text("All) but that looks like a hack and it seems to me this should already be inbuilt into the framework but I can't find anything in the doc's.</p>
  
  <p>EDIT: This is getting even funnier. Due to lack of other options I implemented it like in the note and just set the dataSource pageSize directly:</p>
  
  <pre><code>$("#Grid").data("kendoGrid").dataSource.pageSize(pageSize);
  </code></pre>
  
  <p>But this is causing the filters on grid to malfunction and throw "string is not in correct format" (misleading error) error from the endpoint. After enough research I found out its caused by the DataSourceRequest doing some unidentifiable shuru buru in the background. Since setting the dataSource pageSize causes issues, I tried just setting the dropdown programatically and let kendo trigger the request to update pageSize itself like so:</p>
  
  <pre><code>            var selectBox = $(".k-pager-sizes").find("select");
              selectBox.val(pageSize);
              selectBox.find("option[value='" + pageSize + "']").prop('selected', true);
  </code></pre>
  
  <p>But the grid doesn't let me do it and keeps reverting any changes I do inside the DOM from javascript.</p>
  
  <p>So the question is, how in earth can you change the pageSize of a server-side kendo grid from javascript (triggering an extra request to endpoint).</p>