0
votes

I am trying to use serverPaging with the Kendo UI grid. In order to pass the total pages. I am passing a model which consists of the data list, and the total count. My problem is that I can't figure out how to parse the model in the Kendo grid.

Here is my Controller code:

$scope.mainGridOptions = {
  dataSource: {
      transport: {
          read: {
              url: '/SSQV4/SSQV5/Search/GetSearch',
              type: "GET"
          }
      },
      schema: {
          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"
  }]

};

The data returned is a list ("results"), and the recordcount ("Total"). Normally, I would use a service to get the data and parse the two like below:

    myService.GetSearch()
.success(function(data)){
$scope.myDataList = data.results;
$scope.myDataCount = data.Total;
})

I cannot figure out how to use "results" and "Total" in the Kendo Grid when it is returned by my web api.

Any assistance is greatly appreciated.

1

1 Answers

0
votes

I figured this one out. I had to add "results" to the schema. This worked:

$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"
  }]

};