1

我正在将我的应用程序转换为使用带有 Kendo Grid UI 的服务器端分页。在将 serverPaging 切换为 true 之前,我正在正确显示我的网格内容,并在客户端进行分页。但是,一旦我打开 serverPaging,我的数据就不再可见。我检查了网络调用,我的数据按预期返回(只有 2 条记录,总共 8 条记录),但我没有在网格中看到它。

这是网格结构:

$v.KendoGrid.makeGrid(gridName, {
  columns: [
    { field: 'IdentifierCode', title: 'User Name' },
    { field: 'CompanyName', title: 'Company' },
    { field: 'Email', title: 'Email' }
  ],
  dataSource: {
    pageSize: 2,
    schema: {
      data: 'Data', // records are returned in the data section of the response
      model: {
        id: 'Id',
        fields: {
          IdentifierCode: { type: 'string' },
          CompanyName: { type: 'string' },
          Email: { type: 'string' }
        }
      },
      total: 'Total'    // total number of records are in the total section of the response
    },
    serverPaging: true,
    transport: {
      read: {
        url: window.urlConfigs.root + "Security/UserAccount/PagedListing"
        dataType: "json",
        type: "GET"
      }
    }
  },
  editable: false,
  filterable: true,
  height: 464,
  pageable: true,
  scrollable: true,
  sortable: true
});

这是 MVC 控制器方法:

public ActionResult PagedListing(int pageSize, int skip)
{
    var entities = ReadRepo.All();
    var total = entities.Count();
    var data = entities.Skip(skip).Take(pageSize).Select(MapEntityToViewModel).ToList();

    return Json(new { Total = total, Data = data }, JsonRequestBehavior.AllowGet);
}

这是我在网络调用中得到的数据:

{"Total":8,"Data":[{"Id":"928f0bb2-608b-417b-bf6e-e5c58f85fec2","IdentifierCode":"admin","FirstName":"Administrator","MiddleName":"of","MiddleNameHuman":"of","LastName":"GasStream","DisplayName":"Administrator of GasStream","Email":"admin@example.com","IsExternal":false,"UserTypeHuman":"Internal","CompanyId":"75bb05a4-1ec2-4042-aeba-a229008aca9f","CompanyName":"Entessa Pipeline & Terminal, MLP","CompanyIdentifierCode":"SHA","Password":"wFg/a/NEU6WM8z4YZBUduitIDROfeFz/+Za6leAHnBE=","PasswordChanged":false,"ForceNewPasswordFlag":false,"Settings":[],"RoleGroups":[]},{"Id":"47c29025-cfa8-4447-9ab7-a229008ad088","IdentifierCode":"contractcarl","FirstName":"Carl","MiddleName":null,"MiddleNameHuman":"","LastName":"Smithers","DisplayName":"Carl Smithers","Email":"carl@entessa.com","IsExternal":false,"UserTypeHuman":"Internal","CompanyId":"75bb05a4-1ec2-4042-aeba-a229008aca9f","CompanyName":"Entessa Pipeline & Terminal, MLP","CompanyIdentifierCode":"SHA","Password":"IWdH+qDIOucNrre6V4AgI6Exm2Vq5qkIdXdsWfP6jn4=","PasswordChanged":false,"ForceNewPasswordFlag":false,"Settings":[],"RoleGroups":[]}]}

我怀疑我错过了一些小东西,但是在查看了这个并尝试了各种可能的解决方法之后,我看不到它,所以我正在寻求帮助。我想一旦我得到数据从服务器返回小集合,事情就会变得更简单。

提前致谢,

德鲁

4

1 回答 1

0

我最终找到了答案。$v.KendoGrid 是一种包装 kendoGrid 调用本身的方法,并且在其中某些内容被重置以不允许在从服务器正确分页返回时正确解析数据。

此后我重新处理了这些混乱,因此我可以在 $v.KendoGrid 调用中为我的网格类型建立必要的参数。

感谢您的帮助,以及抓住逗号的眼睛,布雷特。

德鲁

于 2013-09-03T19:44:53.763 回答