2014-05-06 74 views
0

我在一个kendo ui网格上工作。网格默认情况下不可编辑。
在工具栏中有一个'编辑'按钮。当用户点击它时,网格应该可以在批处理模式下编辑,如thiskendo ui网格批量编辑,设置焦点

得到这个工作的唯一解决方案是删除并重新创建网格/数据源与新属性(可编辑:真实等)。

这个按预期工作。现在我想将焦点设置在第一行/单元格上,以便用户可以看到网格现在是可编辑的(在下面的示例中该行变为输入字段)。

对此有何建议?这个是fiddle

$('.k-grid-edit').on('click', function (e) { 
    e.preventDefault(); 

    // remove old grid 
    $('#grid').html(''); 

    // recreate grid with edit: true and new datasource 
    $('#grid').kendoGrid({ 
     dataSource: dataSourceInEdit, 
     editable: true, 
     columns: [{ 
      field: 'TableId', 
      title: 'Id', 
      width: 50 
     }, { 
      field: 'Area', 
      title: 'Area' 
     }, { 
      field: 'Table', 
      title: 'Table', 
      width: 60 
     }, { 
      command: 'destroy', 
      title: ' ', 
      width: 100 
     }] 
    }).data("kendoGrid"); 

}); // end edit 
+0

您可以创建您的问题小提琴?您提供的链接中的网格具有不同的行为! –

+0

@VivekParekh有一个 – chris

回答

0

好吧,我明白了:
这2行做到这一点:

var grid = $("#rt_tableGrid").data("kendoGrid"); 
grid.editRow($("#rt_tableGrid tr:eq(1)")); 

当然只在我的本地脚本,在小提琴我cant't得到它的工作。

中的Docu

虽然写的是:需要“内联”或“弹出”
文档here

+0

我需要将焦点设置在所选行中的特定单元格上?我怎样才能做到这一点?你能帮忙吗? –

+0

这不行吗?对我来说,它选择一个特定的单元格, grid.editRow($('#rtGridEdit tr:eq('+ index +')')); – chris

+0

无法使用你的代码,你的意思是我必须手动指定索引? –