luoyifan 4 years ago
parent
commit
89bdabd1cb
4 changed files with 61 additions and 23 deletions
  1. 4 0
      src/Defaults.ts
  2. 0 21
      src/controls/container.js
  3. 57 0
      src/controls/grid.js
  4. 0 2
      src/init.ts

+ 4 - 0
src/Defaults.ts

@@ -12,6 +12,10 @@ export const combo = {
     autoLoad: true,
 }
 
+export const grid = {
+
+}
+
 export const text = {
     labelAlign: 'right',
     labelWidth: 70,

+ 0 - 21
src/controls/container.js

@@ -1,21 +0,0 @@
-import _ from 'lodash'
-import $ from 'jquery'
-
-export default function () {
-  /**
-   *
-   */
-  const ct = Ext.container.Container.prototype.constructor
-  Ext.container.Container.override({
-    constructor: function (config) {
-      if (config.xtype === "container") {
-        const newConfig = _.defaultsDeep({}, config, {
-          cls: ['yvan_design', 'design_cols_container']
-        })
-        ct.call(this, newConfig)
-      } else {
-        ct.call(this, config)
-      }
-    }
-  });
-}

+ 57 - 0
src/controls/grid.js

@@ -0,0 +1,57 @@
+import _ from 'lodash'
+import {grid} from '../Defaults'
+import {baseConfig} from "./base";
+import {dataSourceReload} from "../DataSourceHelper";
+
+export default function () {
+    const cc = Ext.grid.Panel.prototype.constructor
+    const {initComponent, setData} = Ext.grid.Panel.prototype
+    Ext.grid.Panel.override({
+        constructor(config) {
+            const newConfig = _.defaultsDeep({
+                // 强制性属性
+
+            }, baseConfig(config, 'row-item'), config, grid)
+
+
+            cc.call(this, newConfig)
+        },
+
+        setLoading(value) {
+            if (value) {
+                this.mask()
+            } else {
+                this.unmask()
+            }
+        },
+
+        // reload() {
+        //     dataSourceReload(this)
+        // },
+
+        initComponent() {
+            const that = this
+            this.on({
+                afterrender() {
+                    const {config} = this
+
+                    // if (config.dataSource && config.autoLoad) {
+                    //     dataSourceReload(this)
+                    // }
+                },
+                destory() {
+                },
+                // focus: {
+                //     // 获得焦点后自动下拉
+                //     fn(sender) {
+                //         sender.expand();
+                //         this.doQuery(this.allQuery, true);
+                //     },
+                // },
+            })
+
+            initComponent.call(this)
+        },
+
+    });
+}

+ 0 - 2
src/init.ts

@@ -2,7 +2,6 @@ import _ from 'lodash'
 import initMainTab from './controls/MainTab'
 import initTextfield from './controls/textfield'
 import initToolbar from './controls/toolbar/toolbar'
-import initContainer from './controls/container'
 import initSplitter from './controls/splitter'
 import initCombo from './controls/combo'
 import initRows from './controls/rows'
@@ -62,6 +61,5 @@ export function init() {
     initRows()
     initCols()
     initToolbar()
-    initContainer()
     initSplitter()
 }