Browse Source

appendEditRow(record, editRowCol) 可以根据列名,进入编辑状态

luoyifan 3 năm trước cách đây
mục cha
commit
cf334c945f
1 tập tin đã thay đổi với 6 bổ sung2 xóa
  1. 6 2
      src/controls/grid.js

+ 6 - 2
src/controls/grid.js

@@ -203,13 +203,17 @@ export default function () {
         /**
          * 添加行,并进入编辑状态
          * @param record 新行的属性集
-         * @param editRowCol 要编辑的列序号
+         * @param editRowCol 要编辑的列序号,或 dataIndex 的名称
          */
         appendEditRow(record, editRowCol) {
             const records = this.getStore().add(record)
             const recNew = records[0]
             this.setSelection(records)
 
+            if (typeof editRowCol === 'string' && editRowCol) {
+                editRowCol = this.columns.findIndex((c) => c.dataIndex === editRowCol)
+            }
+
             if (typeof editRowCol === 'number') {
                 const ce = this.findPlugin('cellediting')
                 this.editingPlugin = ce
@@ -439,7 +443,7 @@ export default function () {
                     }
                     const oValue = value
                     if (typeof headers[j].renderer === 'function') {
-                        try{
+                        try {
                             value = headers[j].renderer(value)
                             if (!value && value !== 0) {
                                 value = oValue