ServerPaging request.Page always = 1

2 posts, 0 answers
  1. Beryl
    Beryl avatar
    19 posts
    Member since:
    Jul 2015

    Posted 30 Mar Link to this post

    I am trying to use the Kendo UI grid with serverPaging with Angular and ASP.NET MVC.  Whenever I click "next page" in the grid, when it hits my Action Method, the request object is all zeros accept for Page which is ALWAYS = 1 so my paging never happens  Here is my Angular code:

    <code style="color: #000;">$scope.mainGridOptions = {<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>        dataSource: {<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>            transport: {<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>                read: {<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>                    url: '/SSQV4/SSQV5/Search/GetSearch',<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>                    type: "GET"<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>                }<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>            },<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>            schema: {<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>                data: "results",<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>                total: "Total"<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>            },<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>            pageSize: 25,<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>            serverPaging: true<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">><</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>        },<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>      sortable: true,<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>      pageable: true,<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>      resizable: true,<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">><</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>      columns: [{<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>          field: "CompanyID",<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>          title: "Company ID"<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">><</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>      }, {<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>          field: "CompanyName"<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">><</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>      }, {<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>          field: "City"<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">><</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>      }, {<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>          field: "State"<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">><</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>      }, {<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>          field: "Deficiencies"<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>      }]<</code><code style="color: #069;font-weight: bold;">br</code><code style="color: #000;">>  };</code>

     

    Here is my MVC Controller code:

    public async Task<ActionResult> GetSearch([DataSourceRequest(Prefix = "Grid")] DataSourceRequest request)<br>        {<br>            int pageNum = request.Page;<br>            if (request.PageSize == 0)<br>            {<br>                request.PageSize = 25;<br>            }   <br>            MajorID = UserInfo.intMajorID;<br>            var SearchString = System.Web.HttpContext.Current.Session["SearchString"] as String ?? "";<br>            strSqlQuery = " LEFT JOIN tblSSQReleaseToMajor RT (READUNCOMMITTED) ON C.CompanyID = RT.CompanyID and RT.MajorID = " + MajorID + " LEFT JOIN tblTrainingRelease TR on C.CompanyID = TR.ContractorID";<br> <br>            MajorID = UserInfo.intMajorID;<br>            string preSqlQuery = ""<br><br>            var results = await SearchClient.PostReleasedSearch(preSqlQuery, strSqlQuery, 5000, 1);<br><br>            var searchResults = new SearchResultsViewModel();<br>            searchResults.Total = results.Count();<br>            if (request.Page > 0)<br>            {<br>                results = results.Skip((request.Page - 1) * request.PageSize).ToList();<br>            }<br>            results = results.Take(request.PageSize).ToList();<br><br>            searchResults.results = results;<br><br>            return Json(searchResults, JsonRequestBehavior.AllowGet);<br><br>        }

     

    What am I missing here?

  2. Stefan
    Admin
    Stefan avatar
    912 posts

    Posted 03 Apr Link to this post

    Hello Beryl,

    I noticed that a similar request is already made in another post.

    If they are duplicates, please continue in one of them by your choice.

    The answer is provided in the other post:

    http://www.telerik.com/forums/request-page-always-1

    Regards,
    Stefan
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top