每当我在Kendo网格中展开详细信息行时,我希望获取远程数据来填充详细信息模板。这是我目前的流程:
fyi ...细节行不是kendoGrid。这是#= MyDataField#
这样的标签布局 function detailInit(e) {
var detailRow = e.detailRow;
//Go get the details for the selected row
var ds = new kendo.data.DataSource(
{
transport: {
read: {
data: "d.Data",
dataFilter: function (data) {
var msg = eval('(' + data + ')');
if (msg.hasOwnProperty('d'))
return msg.d;
else
return msg;
},
contentType: "application/json; charset=utf-8",
type: "POST",
dataType: "json",
url: "SearchComponents.aspx/GetComponent"
},
parameterMap: function (options) {
return kendo.stringify({ lpComponentId: e.data.componentid });
}
}
});
ds.fetch(function () {
var data = this.data();
});
//How do i update the detail row with my dataSource?
detailRow.find(".tabstrip").kendoTabStrip({
animation: {
open: { effects: "fadeIn" }
}
});
}
答案 0 :(得分:1)
数据源没有显示它的内在方式,因此您需要决定要显示的内容和格式(例如,数据源中的单个数据项,或每个数据项的表行)数据项,或......)。通常,您只需替换e.detailCell
:
$("#grid").kendoGrid({
columns: [
{ field: "name" }
],
dataSource: [
{
name: "Beverages",
products: [
{ name: "Tea" },
{ name: "Coffee" }
]
},
{
name: "Food",
products: [
{ name: "Ham" },
{ name: "Bread" }
]
}
],
detailInit: function(e) {
// get data
datasource.fetch(function () {
var data = this.data();
// compose your content and write it to the detail cell
e.detailCell.html("this is my content: " + data.length);
});
}
});
您还可以使用detailTemplate作为详细内容的非动态部分,或每个数据项的模板。