Browse Source

grid.dataTransform

luoyifan 3 năm trước cách đây
mục cha
commit
01e154c810
3 tập tin đã thay đổi với 13 bổ sung4 xóa
  1. 1 1
      package.json
  2. 0 1
      src/DataSourceHelper.ts
  3. 12 2
      src/controls/stores.js

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "yvan-ext",
-  "version": "2.0.2",
+  "version": "2.0.3",
   "description": "yvan low-code development platformSuppas.",
   "license": "Apache",
   "main": "dist/yvan-ext.js",

+ 0 - 1
src/DataSourceHelper.ts

@@ -158,7 +158,6 @@ function _innerReload(ctl: any, option: DataSourceParam) {
 
             return
         } else {
-
             console.error("非法的 dataSource", ctl.dataSource)
             debugger
             throw new Error("非法的 dataSource")

+ 12 - 2
src/controls/stores.js

@@ -1,5 +1,5 @@
 import _ from 'lodash'
-import {lookupScope} from "../lib/lib";
+import {lookupScope, lookupFn} from "../lib/lib";
 import {serverInvokeUrlTransform, apiConvert} from "../lib/config";
 import {calcObjectFlat} from '../lib/systemLib'
 
@@ -27,7 +27,17 @@ export function gridInvokeBuild(scope, grid, config, dataSource, reloadParams =
                     rootProperty: 'data',
                     totalProperty: 'pagination.total',
                     successProperty: 'success',
-                    messageProperty: 'msg'
+                    messageProperty: 'msg',
+                    transform: function (data) {
+                        if (grid.dataTransform) {
+                            if (typeof grid.dataTransform === 'string') {
+                                grid.dataTransform = lookupFn(lookupScope(grid), grid.dataTransform)
+                            }
+
+                            return grid.dataTransform.call(grid, data)
+                        }
+                        return data
+                    }
                 }
             },
             listeners: {