所以我使用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
谢谢你帮助我学习如何重新创建这个。也许你可以把它作为答案,我会接受。 –