我有一個kendo-grid,我想打開一個單元格進行編輯。重點是根據行的給定索引打開某個單元格。我在我的應用程序的另一個頁面中獲得了這樣的代碼,它可以很好地工作,但是在這個網格中,它拒絕打開編輯模式。我已經在telerik dojo中嘗試過了,並且它也能按預期工作。Kendo-grid editCell不工作
注意:在我的其他網格代碼完美工作索引需要爲+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)+")");
}
})
當我刪除它不會改變任何東西。 – Alim
並在最後一個添加空間? (「+(index)+」)td:eq(「+(2)+」)「); 順便說一下,行索引從1開始,單元格索引從0開始 –
是啊試過,但也沒有成功(和索引+ 1)。它相當奇怪,因爲如果我用select替換editCell,它會選擇正確的單元格('gridloc.select(「tr:eq(」+(index + 1)+「)td:eq(」+(2)+「)」 );')。 – Alim