我有一个kendo-grid,我想打开一个单元格进行编辑。关键是要根据行的给定索引打开某个单元格。我在我的应用程序的另一个页面中得到了这样的代码,它完美地工作,但是在这个网格中它拒绝打开编辑模式。我已经在telerik dojo中试过这个,并且它也可以按预期工作。
注意:在我的其他网格中,代码完美无缺,索引需要+1才能进行编辑(不选择),但是当我在这里尝试相同时,它没有工作。
代码:
var gridloc = $("#ItemLocGrid").data("kendoGrid");
var dataloc = $("#ItemLocGrid").data("kendoGrid").dataSource;
var alldataloc = gridloc.dataSource.data();
$.each(alldataloc, function (index, item) {
if (item.Barcode == code) {
item.PickedStock++;
item.dirty = true;
console.log(index);
//This works for selecting the right row or the right cell(row 0)
gridloc.select("tr:eq(" + (index) + ")");
gridloc.select("td:eq(" + (2) + ")");
//This works
gridloc.select("tr:eq("+(1)+") td:eq("+ (2) +")");
//This works (but only for row index 0)
gridloc.editCell(gridloc.tbody.find("td").eq(2));
//This doesn't work (should do exactly the same as the line above)
gridloc.editCell("td:eq(" + (2) + ")");
//This is the wanted code which worked in a different grid and dojo
gridloc.editCell("tr:eq("+(index)+")td:eq("+(2)+")");
}
})
答案 0 :(得分:0)
你可以试试这个:
//This doesn't work (should do exactly the same as the line above)
gridloc.editCell("td:eq(" + (2) + ")");
没有括号?
//This doesn't work (should do exactly the same as the line above)
gridloc.editCell("td:eq(" + 2 + ")");
答案 1 :(得分:0)
出于某种原因,我试图重复使用的相同代码在这里不起作用(gridloc.editCell("tr:eq("+(index+1)+") td:eq("+(2)+")");
)。然而,重建它就是诀窍gridloc.editCell(gridloc.tbody.find("tr").eq(index).find("td").eq(2));