title: Kendo, how to do Grid server paging using mvc4 helper
body: <p>I am using mvc4.  On one of my page, it has Kendo Grid.  I want to show 5 rows per page.  I have no problem doing it using pure javascript, however, If I am using  mvc helper. I got lost, couldn't find any samples online.</p>
  
  <p>here's my javascript code.</p>
  
  <pre><code>        &lt;script language="javascript" type="text/javascript"&gt;
  
              $(document).ready(function () {
                  $("#grid").kendoGrid({
                      dataSource: {
                          type: "json",
                          serverPaging: true,
                          pageSize: 5,
                          transport: { read: { url: "Products/GetAll", dataType: "json"} },
                          schema: { data: "Products", total: "TotalCount" }
                      },
                      height: 400,
                      pageable: true,
                      columns: [
                              { field: "ProductId", title: "ProductId" },
                              { field: "ProductType", title: "ProductType" },
                              { field: "Name", title: "Name" },
                              { field: "Created", title: "Created" }
                          ],
                      dataBound: function () {
                          this.expandRow(this.tbody.find("tr.k-master-row").first());
                      }
                  });
              });
  </code></pre>
  
  <p>now if i am using mvc helper</p>
  
  <pre><code>            @(Html.Kendo().Grid(Model)
                  .Name("Grid")  //please help me to finish the rest
  </code></pre>
  
  <p><strong>Update</strong>:</p>
  
  <p>Adding the action code.</p>
  
  <pre><code>    [HttpPost]
      public ActionResult GetAll([DataSourceRequest]DataSourceRequest request, int id)
      {
          var products= ProductService.GetAll(id);
  
          return Json(products.ToDataSourceResult(request));
      }
  </code></pre>
  
  <p>GetAll method in the service layer:</p>
  
  <pre><code>    public IQueryable&lt;Product&gt; GetAll(int id)
      {
          var products= ProductRepository.Get(p =&gt; p.Id== id &amp;&amp; p.IsActive == true, null, "ProductionYear")
                      .OrderBy(o =&gt; o.Name); //.ToList();
  
          return Product.Select(p =&gt; new ProductVM()
          {
              Name = p.Name,
              ProductionYear= p.ProductionYear.Year.ToString()
              Id = p.Id
          }).AsQueryable();
      }
  </code></pre>
  
  <p>now, if I run the app, i will get following error:</p>
  
  <p>"LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression."}</p>
  
  <p>in the GetAll method, I comment out the "ToList()". If I use ToList, everything works. but I will query all the rows back instead just those rows I needed for that page.</p>