ExtJS摘编(后续其它)

1. ExtJS的grid的按键,默认是Enter(Shift+Enter)上下移动光标,TAB(Shift+Tab)左右移动光标。

但大多数时候,用户希望Enter左右移到,所以作此转换。

      在建立grid后,直接调用下属代码,你也可以按照下面思路,自己做上下箭头移动。

        //grid 是你的EditorGrid的名。

       var sm = grid.getSelectionModel();

         sm.onEditorKey = function(field, e) {
             var k = e.getKey(), newCell, g = sm.grid, ed = g.activeEditor;
             if (k == e.ENTER) {
                 e.stopEvent();
                 ed.completeEdit();
                 if (e.shiftKey) {
                     newCell = g.walkCells(ed.row, ed.col - 1, -1, sm.acceptsNav, sm);
                 } else {
                     newCell = g.walkCells(ed.row, ed.col + 1, 1, sm.acceptsNav, sm);
                 }
             } else if (k == e.TAB) {
                 e.stopEvent();
                 ed.completeEdit();
                 if (e.shiftKey) {
                     newCell = g.walkCells(ed.row-1, ed.col, -1, sm.acceptsNav, sm);
                 } else {
                     newCell = g.walkCells(ed.row+1, ed.col, 1, sm.acceptsNav, sm);
                 }
                 if (ed.col == 1) {
                     if (e.shiftKey) {
                         newCell = g.walkCells(ed.row, ed.col + 1, -1, sm.acceptsNav, sm);
                     } else {
                         newCell = g.walkCells(ed.row, ed.col + 1, 1, sm.acceptsNav, sm);
                     }
                 }
             } else if (k == e.ESC) {
                 ed.cancelEdit();
             }
             if (newCell) {
                 g.startEditing(newCell[0], newCell[1]);
             }

         };

 

 

 2. 控制Grid中某一个单元格是否可以编辑(。。。)

 

相关文章:

  • 2022-01-01
  • 2022-12-23
  • 2022-01-15
  • 2021-07-05
  • 2021-11-14
  • 2021-07-19
  • 2021-12-22
  • 2021-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-21
  • 2021-12-23
  • 2022-12-23
相关资源
相似解决方案