简体   繁体   中英

Kendo-grid editCell not working

I have a kendo-grid in which I want to open up a cell for editing. The point is to open up a certain cell based on a row's given index. I got code like this in another page of my application where it works perfectly however in this grid it refuses to open up the editing mode. I've tried this in a telerik dojo aswell where it also works as intended.

Note: In my other grid where the code works perfectly the index needed to be +1 for editing (not selecting), however when I tried the same here it didn't work.

Code:

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)+")");
}
})  

Could you try this:

//This doesn't work (should do exactly the same as the line above)
gridloc.editCell("td:eq(" + (2) + ")");  

without parenthesis?

//This doesn't work (should do exactly the same as the line above)
gridloc.editCell("td:eq(" + 2 + ")"); 

For some reason the same code I tried to re-use didn't work here
gridloc.editCell("tr:eq("+(index+1)+") td:eq("+(2)+")");
However rebuilding it to this did the trick gridloc.editCell(gridloc.tbody.find("tr").eq(index).find("td").eq(2));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM