Browse Source

grid ischanged

luoyifan 3 years ago
parent
commit
d294612c60
2 changed files with 39 additions and 5 deletions
  1. 38 4
      dist/yvan-ext.js
  2. 1 1
      dist/yvan-ext.js.map

+ 38 - 4
dist/yvan-ext.js

@@ -95289,10 +95289,45 @@ define(['exports'], function (exports) { 'use strict';
             _setDataReal: function (value) {
                 var me = this;
                 this._transform(value);
-                me.setStore(new Ext.data.Store({
+                var store = new Ext.data.Store({
                     fields: getFileds(this),
-                    data: value
-                }));
+                    data: value,
+                });
+                me.setStore(store);
+            },
+            setStore: function (store) {
+                var me = this;
+                me.superclass.setStore.call(this, store);
+                var reference = this.reference;
+                if (reference) {
+                    lookupScope(this).viewModel.set(reference + '.ischanged', false);
+                }
+                store.on({
+                    add: function (store, records, index, eOpts) {
+                        me._raiseChange(store, 'add');
+                    },
+                    remove: function (store, records, index, isMove, eOpts) {
+                        me._raiseChange(store, 'remove');
+                    },
+                    datachanged: function (sender, opt) {
+                        me._raiseChange(store, 'datachanged');
+                    }
+                });
+            },
+            _raiseChange: function (store, type) {
+                var reference = this.reference;
+                if (reference && store) {
+                    var ischanged = false;
+                    if (store.getModifiedRecords().length > 0 ||
+                        store.getNewRecords().length > 0 ||
+                        store.getRemovedRecords().length > 0) {
+                        ischanged = true;
+                    }
+                    else {
+                        ischanged = false;
+                    }
+                    lookupScope(this).viewModel.set(reference + '.ischanged', ischanged);
+                }
             },
             /**
              * 轻量级刷新
@@ -95792,7 +95827,6 @@ define(['exports'], function (exports) { 'use strict';
         }
         // throw new TypeError('无法识别的调用方法')
     }
-    //# sourceMappingURL=grid.js.map
 
     function initTextfield () {
         var cc = Ext.form.field.Text.prototype.constructor;

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