所以我使用Kendo Ui創建了網格,並且在這個網格中我有一個詳細的行模板。我創建這樣這是一個Kendo Ui Grid的bug嗎?
$(document).ready(function() {
var theModel = @(Html.Raw(Json.Encode(Model.Datas)));
//If the model is empty then create the No data Grid
if (theModel.length < 1) {
$("#AccessGrid").kendoGrid({
columns:[
{
field: "Message",
title: " "
}
],
dataSource: [{Message:"No data"}]
});
} else {//create the normal grid
$("#AccessGrid").kendoGrid({
columns:[
{
field: "ProjNo",
title: "Project #"
},
{
field: "ProjType",
title: "Job Type"
},
{
field: "ProjAddress",
title: "Address"
}],
selectable:true,
scrollable:false,
dataSource:theModel,
detailTemplate: kendo.template($("#AcccessDetailTemplate").html()),
detailInit:initDetailGrid
});
}
});
和initDetailGrid(e)
主電網被用來創建細節電網
function initDetailGrid(e) {
var grid = e.sender;
var currentDataItem = grid.dataItem(grid.select()); //Get the data for the selected row
//if there are no data in intExtData then create a default obj
if (currentDataItem.InternalData == null||currentDataItem.InternalData == undefined||currentDataItem.InternalData.length < 1) {
currentDataItem.InternalData = [{
TaskId:-1,
Internal: -1,
Sequence: -1
}];
}
e.detailRow.find("[name='AcccessDetail']").kendoGrid({
columns:[
{
field:"TaskId",
title: "<input type='checkbox' onclick='AccessModal.checkAll(event)'/>",
template:$("#detailInputColumnTemplate").html(),
width: "35px"
},
{
field: "Internal",
title: " ",
template:$("#detailColumnTemplate").html()
}
],
scrollable:false,
dataSource:currentDataItem.InternalData
});
}
的問題是,有時不顯示的一行或多行我的詳細信息模板和誤差拋出說Uncaught TypeError: Cannot read property 'InternalData' of null
,但怎麼可能呢?我知道那裏有數據,因爲如果我刷新並單擊行細節,數據就會顯示出來。這並非一直髮生,但它足以讓我注意到。有沒有人遇到過這樣的事情
當你點擊一個按鈕的細節,電網必須選擇行,其中包括該按鈕,但如果您移動鼠標的時候還是點擊,電網不選擇任何行。所以'var currentDataItem = grid.dataItem(grid.select()); '由於'grid.select()'而出錯。在我看來,是的,這是一個錯誤。 – MustafaP
特別嘗試使用chrome.hold單擊詳細按鈕,向左或向右移動鼠標3或4 px,然後擡起鼠標。 – MustafaP
謝謝你幫助我學習如何重新創建這個。也許你可以把它作爲答案,我會接受。 –