This is a migrated thread and some comments may be shown as answers.

request.Page always 1

1 Answer 98 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Beryl
Top achievements
Rank 1
Beryl asked on 30 Mar 2017, 09:55 PM

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.

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 03 Apr 2017, 10:03 AM
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 (charts) and form elements.
Tags
Grid
Asked by
Beryl
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or