Kendo Grid Hierarchy View - 如何填充现有和相关的dataSource?

时间:2014-11-26 11:14:18

标签: jquery kendo-ui telerik kendo-grid

我想使用Hierarchy Grid,它包含来自读取请求的数据。

http://demos.telerik.com/kendo-ui/grid/hierarchy

问题是函数 detailInit 正在处理第二个请求,但我想从wxisting数据源获取和更新数据。

问题是:

如何在现有数据源中显示和更新(在数据集上)所选行的相关数据?

初始化的功能点击行展开箭头:

function detailInit(e) {
      alert("TEST");
      $("<div/>").appendTo(e.detailCell).kendoGrid({
        dataSource: {
          type: "odata",
          transport: {
            read: "http://demos.telerik.com/kendo-ui/service/Northwind.svc/Orders"
          },
          serverPaging: true,
          serverSorting: true,
          serverFiltering: true,
          pageSize: 10,
          filter: { field: "EmployeeID", operator: "eq", value: e.data.EmployeeID }
        },
        scrollable: false,
        sortable: true,
        pageable: true,
        columns: [
          { field: "OrderID", width: "70px" },
          { field: "ShipCountry", title:"Ship Country", width: "110px" },
          { field: "ShipAddress", title:"Ship Address" },
          { field: "ShipName", title: "Ship Name", width: "300px" }
        ]
      });
    };

非常感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

为什么不尝试从之前创建的master datasoruce中获取数据源。你可以写

function detailInit(e) {
      alert("TEST");
      $("<div/>").appendTo(e.detailCell).kendoGrid({
         // you should gather masterDataSource here or get from function parameter
         dataSource: {
             data: masterDataSourceName,
             pageSize: 10,
             schema: {
                 model: {
                     fields: {
                        field: "EmployeeID"
                     }
                 }
             }
        },
        scrollable: false,
        sortable: true,
        pageable: true,
        columns: [
          { field: "OrderID", width: "70px" },
          { field: "ShipCountry", title:"Ship Country", width: "110px" },
          { field: "ShipAddress", title:"Ship Address" },
          { field: "ShipName", title: "Ship Name", width: "300px" }
        ]
      });
    };
像这样。如果你没有masterDataSource,你应该从你的数据库中收集它。

相关问题