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 server-side paging in my project I am using Angular, and Asp.net MVC.  Whenever click "next page" the request object values are always 0 accept for Page which is always 1.  Because the page is always 1, I can't ever move to the next page.

    Here is my Angular code:

     $scope.mainGridOptions = {
            dataSource: {
                transport: {
                    read: {
                        url: '/SSQV4/SSQV5/Search/GetSearch',
                        type: "GET"
                    }
                },
                schema: {
                    data: "results",
                    total: "Total"
                },
                pageSize: 25,
                serverPaging: true
            },
          sortable: true,
          pageable: true,
          resizable: true,
          columns: [{
              field: "CompanyID",
              title: "Company ID"
          }, {
              field: "CompanyName"
          }, {
              field: "City"
          }, {
              field: "State"
          }, {
              field: "Deficiencies"
          }]
      };

    Here is my MVC Controller code:

     

    public async Task<ActionResult> GetSearch([DataSourceRequest(Prefix = "Grid")] DataSourceRequest request)
            {
                int pageNum = request.Page;
                if (request.PageSize == 0)
                {
                    request.PageSize = 25;
                }   
                MajorID = UserInfo.intMajorID;
                var SearchString = System.Web.HttpContext.Current.Session["SearchString"] as String ?? "";
                strSqlQuery = " LEFT JOIN tblSSQReleaseToMajor RT (READUNCOMMITTED) ON C.CompanyID = RT.CompanyID and RT.MajorID = " + MajorID + " LEFT JOIN tblTrainingRelease TR on C.CompanyID = TR.ContractorID";
     
                MajorID = UserInfo.intMajorID;
                string preSqlQuery = ""

                var results = await SearchClient.PostReleasedSearch(preSqlQuery, strSqlQuery, 5000, 1);

                var searchResults = new SearchResultsViewModel();
                searchResults.Total = results.Count();
                if (request.Page > 0)
                {
                    results = results.Skip((request.Page - 1) * request.PageSize).ToList();
                }
                results = results.Take(request.PageSize).ToList();

                searchResults.results = results;

                return Json(searchResults, JsonRequestBehavior.AllowGet);

            }

    Why is page always 1?  If I click on Page 2, 3, the request object page is always 1.

    Any assistance is greatly appreciated.

  2. Stefan
    Admin
    Stefan avatar
    1025 posts

    Posted 03 Apr Link to this post

    Hello Beryl,

    When serverPaging is set, the Grid will send the skip, top, page and pageSize parameters and based on them the correct data for the page have to be sent. I was not able to reproduce the scenario where the Grid is not sending the correct page parameter:

    http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-serverPaging

    I can suggest using the parameterMap function to check the actual parameters which are sent from the Grid, this will also allow to modify them:

    http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-transport.parameterMap

    If the correct parameters are sent from the Grid, please check if there is an additional custom logic which is interfering with the Grid behaviour.

    If the Grid is not sending the correct parameters, please send a fully runnable example reproducing the issue and I will gladly assist.

    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