Browse Source

// 表格内编辑器,按上下键时,可以切换到下一行/上一行 进入编辑

luoyifan 3 years ago
parent
commit
dfce13eefd
2 changed files with 71 additions and 10 deletions
  1. 70 9
      dist/yvan-ext.js
  2. 1 1
      dist/yvan-ext.js.map

+ 70 - 9
dist/yvan-ext.js

@@ -95856,14 +95856,33 @@ define(['exports'], function (exports) { 'use strict';
                                 sender.fireEvent('click', _this, e);
                             });
                             jquery(sender.inputEl.dom).on('keydown', function (e) {
-                                if (e.code === "ArrowDown") {
-                                    debugger;
-                                    e.stopPropagation();
-                                    e.preventDefault();
-                                }
-                                else if (e.code === "ArrowUp") {
-                                    e.stopPropagation();
-                                    e.preventDefault();
+                                var _a, _b, _c, _d, _e;
+                                // 表格内编辑器,按上下键时,可以切换到下一行/上一行 进入编辑
+                                if (e.code === "ArrowDown" || e.code === 'ArrowUp') {
+                                    if (((_a = sender.ownerCt) === null || _a === void 0 ? void 0 : _a.xtype) === 'celleditor') {
+                                        var grid = sender.ownerCt.up('grid');
+                                        var editingPlugin = grid.editingPlugin || grid.ownerGrid.editingPlugin;
+                                        if (editingPlugin) {
+                                            var rowIdx = (_c = (_b = editingPlugin === null || editingPlugin === void 0 ? void 0 : editingPlugin.activeEditor) === null || _b === void 0 ? void 0 : _b.context) === null || _c === void 0 ? void 0 : _c.rowIdx;
+                                            var colIdx = (_e = (_d = editingPlugin === null || editingPlugin === void 0 ? void 0 : editingPlugin.activeEditor) === null || _d === void 0 ? void 0 : _d.context) === null || _e === void 0 ? void 0 : _e.colIdx;
+                                            if (typeof rowIdx !== 'undefined' && typeof colIdx !== 'undefined') {
+                                                // editingPlugin
+                                                var targetRecord = void 0;
+                                                if (e.code === 'ArrowDown') {
+                                                    targetRecord = grid.store.data.getAt(rowIdx + 1);
+                                                }
+                                                else {
+                                                    targetRecord = grid.store.data.getAt(rowIdx - 1);
+                                                }
+                                                if (targetRecord) {
+                                                    grid.setSelection([targetRecord]);
+                                                    editingPlugin.startEdit(targetRecord, colIdx);
+                                                }
+                                                e.stopPropagation();
+                                                e.preventDefault();
+                                            }
+                                        }
+                                    }
                                 }
                             });
                         }
@@ -95873,6 +95892,7 @@ define(['exports'], function (exports) { 'use strict';
             }
         });
     }
+    //# sourceMappingURL=textfield.js.map
 
     function initTbFill () {
         /**
@@ -96502,7 +96522,6 @@ define(['exports'], function (exports) { 'use strict';
             },
         });
     }
-    //# sourceMappingURL=datefield.js.map
 
     function initDateTimePicker () {
         Ext.define('Yvan.DateTimePicker', {
@@ -96968,6 +96987,48 @@ define(['exports'], function (exports) { 'use strict';
                 cc.call(this, newConfig);
             },
             initComponent: function () {
+                this.on({
+                    afterrender: function (sender) {
+                        var _this = this;
+                        var _a;
+                        if ((_a = sender.inputEl) === null || _a === void 0 ? void 0 : _a.dom) {
+                            sender.inputEl.dom.setAttribute('spellcheck', "false");
+                            jquery(sender.inputEl.dom).on('click', function (e) {
+                                sender.fireEvent('click', _this, e);
+                            });
+                            jquery(sender.inputEl.dom).on('keydown', function (e) {
+                                var _a, _b, _c, _d, _e;
+                                // 表格内编辑器,按上下键时,可以切换到下一行/上一行 进入编辑
+                                if (e.code === "ArrowDown" || e.code === 'ArrowUp') {
+                                    if (((_a = sender.ownerCt) === null || _a === void 0 ? void 0 : _a.xtype) === 'celleditor') {
+                                        var grid = sender.ownerCt.up('grid');
+                                        var editingPlugin = grid.editingPlugin || grid.ownerGrid.editingPlugin;
+                                        if (editingPlugin) {
+                                            var rowIdx = (_c = (_b = editingPlugin === null || editingPlugin === void 0 ? void 0 : editingPlugin.activeEditor) === null || _b === void 0 ? void 0 : _b.context) === null || _c === void 0 ? void 0 : _c.rowIdx;
+                                            var colIdx = (_e = (_d = editingPlugin === null || editingPlugin === void 0 ? void 0 : editingPlugin.activeEditor) === null || _d === void 0 ? void 0 : _d.context) === null || _e === void 0 ? void 0 : _e.colIdx;
+                                            if (typeof rowIdx !== 'undefined' && typeof colIdx !== 'undefined') {
+                                                // editingPlugin
+                                                var targetRecord = void 0;
+                                                if (e.code === 'ArrowDown') {
+                                                    targetRecord = grid.store.data.getAt(rowIdx + 1);
+                                                }
+                                                else {
+                                                    targetRecord = grid.store.data.getAt(rowIdx - 1);
+                                                }
+                                                if (targetRecord) {
+                                                    grid.setSelection([targetRecord]);
+                                                    editingPlugin.startEdit(targetRecord, colIdx);
+                                                }
+                                                e.stopPropagation();
+                                                e.preventDefault();
+                                            }
+                                        }
+                                    }
+                                }
+                            });
+                        }
+                    }
+                });
                 initComponent.call(this);
             },
         });

File diff suppressed because it is too large
+ 1 - 1
dist/yvan-ext.js.map