如何确保每次都能调用kendo grid detailInit
How to make sure that kendo grid detailInit can be called everytime
我有一个使用 detailInit 的 kendo 网格,当你 select 一行时它只会被调用一次,如果你重新 select 那一行它就不会再次开火。我的问题是我每次都需要触发 detailInit,因为我里面有一个网格,每次查看它时都需要调用服务器,以便数据是最新的。
我想到的一种方法是使用全局变量作为对象,并在触发 detailInit 时传入 masterrow 的 id,然后在 change 事件上检查全局变量以查看该行是否已经被打开,如果有则调用服务器。但我不确定这是否是最好的方法...
有什么想法吗?
在 detailExpand 您可以更改 detailRow 数据源(重新打开时):
$("#grid").kendoGrid({
columns: [
{ field: "name" }
],
dataSource: [
{
name: "Beverages"
},
{
name: "Food",
products: [
{ name: "Ham" },
{ name: "Bread" }
]
}
],
detailTemplate: 'Products: <div class="grid"></div>',
detailExpand: function(e) {
console.log("expand: ", e);
var selectedColumnName = e.sender.dataItem(e.masterRow).name;
console.log(selectedColumnName);
e.detailRow.find(".grid").kendoGrid({
dataSource: [
{ name: "Tea" },
{ name: "Coffee" }
]
});
}
});
我有一个使用 detailInit 的 kendo 网格,当你 select 一行时它只会被调用一次,如果你重新 select 那一行它就不会再次开火。我的问题是我每次都需要触发 detailInit,因为我里面有一个网格,每次查看它时都需要调用服务器,以便数据是最新的。
我想到的一种方法是使用全局变量作为对象,并在触发 detailInit 时传入 masterrow 的 id,然后在 change 事件上检查全局变量以查看该行是否已经被打开,如果有则调用服务器。但我不确定这是否是最好的方法...
有什么想法吗?
在 detailExpand 您可以更改 detailRow 数据源(重新打开时):
$("#grid").kendoGrid({
columns: [
{ field: "name" }
],
dataSource: [
{
name: "Beverages"
},
{
name: "Food",
products: [
{ name: "Ham" },
{ name: "Bread" }
]
}
],
detailTemplate: 'Products: <div class="grid"></div>',
detailExpand: function(e) {
console.log("expand: ", e);
var selectedColumnName = e.sender.dataItem(e.masterRow).name;
console.log(selectedColumnName);
e.detailRow.find(".grid").kendoGrid({
dataSource: [
{ name: "Tea" },
{ name: "Coffee" }
]
});
}
});