Kendo MVC 网格层次结构 - 从父 Ienumerable 生成的子网格 属性

Kendo MVC grid hierarchy - child grid generated from parent Ienumerable property

所以,我对使用 Kendo 非常陌生,而且我弄乱了他们的 MVC 网格。我定义了一个带有 ajax 数据源的网格,用于服务器端分页和排序。 ajax 调用 returns 的对象有一个 属性,它是一个 IEnumerable。我想使用网格的分层功能将此集合显示为每一行的子网格。

我已经阅读了很多关于分层网格的博客和 Telerik 的文档,我发现的每个示例都为子网格定义了一个客户端模板,并且该客户端模板是一个网格,它使一个单独的 ajax 调用以获取其数据。 我不需要也不想单独调用子网格,因为我已经在父网格模型中获得了我需要的所有数据。

有什么方法可以完成我想做的事情吗?

描述的场景可以这样实现:

  • 主数据项应该有一个字段,其值是普通对象数组 - 根据您所说的,您应该已经有了。
  • 主网格配置应该定义一个 client detail template 和一个子网格,该子网格定义了列、Ajax 数据源和模型类型,但不绑定到任何特定数据(即没有Read() 行动)。
  • detailInit event of the master Grid, get() the nested array from the master data item (e.data), and assign it via data() to the detail Grid's dataSource 实例中。

http://dojo.telerik.com/iLAza

您可能会注意到 toJSON() in the example above. Its purpose is to strip the nested Features array of all Kendo-UI-specific ObservableObject 东西的用法,并将其转换回普通对象的常规 JavaScript 数组。此步骤是可选的,但如果您想将详细网格的数据与主网格中的数据分离,则此步骤是必需的。