0
我正在使用劍道網格,它的工作正常。我需要檢查我的網格的每一行,如果它包含一個特定的值,然後使用一個模板綁定數據,否則模板將會不同。這可能嗎 ?這裏是我的代碼劍道網格,根據條件顯示不同的模板詳細網格
function detailInit(e) {
var isCreateGrid = true;
var masterRowId = e.data.uid;
var data = [];
$.ajax({
type: "GET",
url: 'https://www.domain.com/details?&transactionId=' + e.data.TransactionId,
contentType: "application/json; charset=utf-8",
dataType: 'json',
headers: { 'ccode': compCode },
cache: false,
async: false,
success: function (result) {
var jsonResult = JSON.parse(result);
for (var i = 0; i < jsonResult.length; i++) {
if (jsonResult[i]["OldValue"] == null || jsonResult[i]["OldValue"] == '')
isCreateGrid = true;
else {
isCreateGrid = false;
break;
}
}
if (isCreateGrid) {
for (var i = 0; i < jsonResult.length; i++) {
data.push({ FieldUpdated: jsonResult[i]["ChangeColumns"], Value: jsonResult[i]["NewValue"] });
}
} else {
for (var i = 0; i < jsonResult.length; i++) {
data.push({ FieldUpdated: jsonResult[i]["ChangeColumns"], Was: jsonResult[i]["OldValue"], Now: jsonResult[i]["NewValue"] });
}
}
}
});
var dataSource = new kendo.data.DataSource({ data: data });
if (data.length == 0) {
var grid = $("#logs").data("kendoGrid");
grid.collapseRow("[data-uid='" + masterRowId + "']");
grid.dataSource.read();
} else {
if (isCreateGrid) {
$("<div/>").appendTo(e.detailCell).kendoGrid({
dataSource: dataSource,
filter: { field: e.data.Log, operator: "contains", value: 'has created' },
columns:
[{ field: "FieldUpdated", title: "Field Updated", width: "50px" },
{ field: "Value", title: "Value", width: "50px" }]
});
} else {
$("<div/>").appendTo(e.detailCell).kendoGrid({
dataSource: dataSource,
filter: { field: e.data.Log, operator: "contains", value: 'has created' },
columns:
[{ field: "FieldUpdated", title: "Field Updated", width: "50px" },
{ field: "Was", title: "Was", width: "50px" },
{ field: "Now", title: "Now", width: "50px" }]
});
}
}
}
但這isCreateGrid
條件似乎是無用的,因爲如果他發現任何行,其中isCreateGrid
標準是錯誤的,那麼所有的行會針對錯誤的標準模板。
您可以在網格的數據綁定事件中保持isCreateGrid的條件檢查 – 2015-02-09 08:54:52