2013-04-10 108 views

回答

7

这就像主电网。作为childgrid网格对应于细节,做到:

var row = childgrid.select(); 
var data = childgrid.dataItem(row); 
console.log("row", row); 
console.log("data", data); 

哪里定义master格为:当主电网连续扩大

$("#grid").kendoGrid({ 
    ... 
    detailInit: detailInit, 
    ... 
}); 

和细节网格使用下面的函数创建:

function detailInit(e) { 
    childgrid = $("<div/>").appendTo(e.detailCell).kendoGrid({ 
     dataSource: { 
      type: "odata", 
      transport: { 
       read: "http://demos.kendoui.com/service/Northwind.svc/Orders" 
      }, 
      serverPaging: true, 
      serverSorting: true, 
      serverFiltering: true, 
      pageSize: 5, 
      filter: { field: "EmployeeID", operator: "eq", value: e.data.EmployeeID } 
     }, 
     scrollable: false, 
     sortable: false, 
     selectable: 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: "200px" } 
       ] 
    }).data("kendoGrid"); 
} 

运行例如这里:http://jsfiddle.net/OnaBai/2M86L/(当你点击Show按钮,它在控制台o显示在浏览器中选择所选行及其数据)。

+0

感谢OnaBai,我现在能够做的它,我没有得到网格实例。这是我的错误。 – 2013-04-11 02:49:43

+0

我试图从一个网格中选择多行并将这些行分配给另一个网格。我怎样才能做到这一点?请帮忙。 – 2013-11-24 05:16:22

+1

@Jain,你不应该问问题作为评论,因为这会阻止他人找到已经问过的问题的解决方案。尝试发布一个新问题,我很乐意为您提供帮助。谢谢! – OnaBai 2013-11-24 17:43:39

0

这里就如何获得的点击行的数据稍微简单的例子:http://jsfiddle.net/Corne/AQqMH/5/

这就是魔法发生代码:

change: function (arg) {    
    var selectedData = this.dataItem(this.select()); 

    // selectedData now points to the selected dataSource item! 

    alert("Clicked id: " + selectedData.id); 
}   
相关问题