【问题标题】:Kendo-grid editCell not working剑道网格编辑单元不起作用
【发布时间】:2017-10-09 07:53:49
【问题描述】:

我有一个剑道网格,我想在其中打开一个单元格进行编辑。关键是根据行的给定索引打开某个单元格。我在我的应用程序的另一个页面中得到了这样的代码,它可以完美地工作,但是在这个网格中它拒绝打开编辑模式。我也在 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)+")");
}
})  

【问题讨论】:

    标签: javascript telerik kendo-grid


    【解决方案1】:

    你可以试试这个:

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

    【讨论】:

    • 删除它时不会改变任何东西。
    • 并在最后一个中添加一个空格? gridloc.editCell("tr:eq("+(index)+") td:eq("+(2)+")");顺便说一句,行索引从 1 开始,单元格索引从 0 开始
    • 是的,也试过了,但没有成功(索引+1)。这很奇怪,因为如果我将 editCell 替换为 select 它确实会选择正确的单元格 (gridloc.select("tr:eq("+(index+1)+") td:eq("+(2)+")");)。
    • 是的,很奇怪..看这段代码dojo.telerik.com/eQEzE/5,使用select函数选择33岁,使用editCell函数编辑30岁
    • 是的,虽然在索引中添加 +1 应该可以解决这个问题,但它只是没有做任何事情。 td:eq(2) 不起作用但 tbody.find("td").eq(2) 起作用也很奇怪。
    【解决方案2】:

    由于某种原因,我尝试重复使用的相同代码在这里不起作用
    gridloc.editCell("tr:eq("+(index+1)+") td:eq("+(2)+")");
    但是,将其重建为这个技巧gridloc.editCell(gridloc.tbody.find("tr").eq(index).find("td").eq(2));

    【讨论】:

      猜你喜欢
      • 2014-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多