dojo增强的datagrid在编辑后失去焦点

时间:2014-03-17 03:42:38

标签: datagrid dojo edit

我有一个使用datagrid的增强型jsonreststore

我已将可编辑单元格设置为自动保存。为此,我添加了一个onApplyCellEdit属性。成功保存后(通过按Enter键),服务器将使用新数据进行响应,并更新datagrid。然而,对刚刚编辑过的细胞的关注失去了焦点。结果我无法使用箭头键导航到下一个单元格,迫使我使用鼠标。有没有办法重新获得焦点,以便我可以在编辑后使用键盘进行导航? 我已经完成了以下代码,以便使用setTimeout重新获得焦点,但我认为这不是一个好的解决方案,因为如果服务器需要太长时间才能响应,那么单元格将首先重新获得焦点,并且当响应进入时细胞更新后,细胞将失去焦点:

 var accounts = new EnhancedGrid({
     structure: account_layout,
     selectionMode: "single",
     canSort: function(){
         return false
     },
     onApplyCellEdit: function(inValue,inRowIndex,inFieldIndex){
         if(this.store){
             this.store.save();
             window.setTimeout(function(){
                 var cells = accounts.layout.cells;
                 var fieldLocation;

                 for(var i = 0; i < cells.length; i++){
                     if(inFieldIndex === cells[i].field){
                         fieldLocation = i;
                         break;
                     }
                 }
                 accounts.focus.setFocusCell(cells[fieldLocation],inRowIndex);
             },500);
         }
     }
 });

我也尝试过:

this.store.save().then(function(){ ...});

但它不起作用。

修改 为了澄清问题,我在第2段的第一句后添加了句子。

0 个答案:

没有答案