2014-01-16 30 views
0

我有一個網格,有單元格編輯和行選擇模型。我使用tab轉到下一個單元格並開始編輯它,但是有一些單元格需要跳過編輯,但是當壓縮標籤頁時需要轉到下一個可編輯單元格。EXTJS 4 - 如何通過網格使用Tab鍵時跳過單個單元格,但保持標籤按下開始編輯下一個可編輯單元格?

如果我只是從「beforeedit」事件中「返回false」,它取消了整個編輯過程,所以我需要再次使用鼠標,那是錯誤的。

我該如何使用skipp單元但保持tab鍵工作?

 plugins: [ 
      Ext.create('Ext.grid.plugin.CellEditing', { 
       clicksToEdit: 1, 
       listeners: { 
        beforeedit: { 
         fn: me.onCellEditingBeforeEdit, 
         scope: me 
        } 
       } 
      }) 
     ] 

這裏是之前編輯功能:

onCellEditingBeforeEdit: function(editor, e, eOpts) { 

    var isEditable=this.isCellEditabe(editor, e); // return false if the cell is not editable 

    if (!isEditable) 
    { 
     return false; 
    } 

} 
+0

你的代碼在哪裏?你應該放在這裏,然後我們可以想到它! –

+0

我不認爲這是必要的。但我編輯了原文。 – HyGy

+0

看到我的答案在http://stackoverflow.com/questions/16016073/how-to-skip-over-particular-cells-when-tabbing-through-an-ext-grid/37680711#37680711 – firnnauriel

回答

0

我發現某處在.NET論壇的解決方案:

Ext.selection.RowModel.override({ 
     onEditorTab: function(editingPlugin, e) { 
      var me = this, 
      view = me.views[0], 
      record = editingPlugin.getActiveRecord(), 
      header = editingPlugin.getActiveColumn(), 
      position = view.getPosition(record, header), 
      direction = e.shiftKey ? 'left' : 'right', 
      columnHeader; 

     // We want to continue looping while: 
     // 1) We have a valid position 
     // 2) There is no editor at that position 
     // 3) There is an editor, but editing has been cancelled (veto event) 

     do { 
      position = view.walkCells(position, direction, e, me.preventWrap); 
      columnHeader = view.headerCt.items.getAt(position.column); 
     } while (position && (!columnHeader.getEditor(record) || !editingPlugin.startEditByPosition(position))); 
    }  
}); 
0

將此作爲配置在當前電網:

var grid = Ext.create('Ext.grid.Panel', { 
    ... 
    selModel: Ext.create('selection.cellmodel', { 
     onEditorTab: function(editingPlugin, e) { 
      var me = this, 
       direction = e.shiftKey ? 'left' : 'right', 
       position = me.move(direction, e); 

      if (position) { 
       while(!editingPlugin.startEdit(position.row, position.column)){ 
        position = me.move(direction, e); 

        // go to first editable cell 
        if(!position) editingPlugin.startEdit(0, 1); // TODO: make this dynamic 
       } 
       me.wasEditing = false; 

      } else { 
       // go to first editable cell 
       if (editingPlugin.startEdit(0, 1)) { // TODO: make this dynamic 
        me.wasEditing = false; 
       } 
      } 
     }, 
    }), 
    //selType: 'cellmodel', // remove selType 
    ... 
}) 
相關問題