Extjs4 Store异步提交

配置Store:

 1 configProxy: function(action){
 2         return {
 3             type : 'ajax',
 4             reader : {
 5                 type: 'json',
 6                 root: 'data',
 7                 idProperty: 'id',
 8                 totalProperty: 'totalCount',
 9                 successProperty: 'success'
10             },
11             actionMethods: {
12                 create : 'POST',
13                 read   : 'POST',
14                 update : 'POST',
15                 destroy: 'POST'
16             },
17             writer: {
18                 type: 'json',
19                 allowSingle: false,
20                 encode: false,
21                 writeAllFields: true
22             },
23             api: {
24                 create: Ext.String.format('{0}!save.action',action),
25                 read: Ext.String.format('{0}!findAll.action',action),
26                 update: Ext.String.format('{0}!update.action',action),
27                 destroy: Ext.String.format('{0}!remove.action',action)
28             }
29         };
30     }

提交:

 1 doSyncStore: function(store){
 2         if (store.canValid()){
 3             if (store.canSync()){
 4                 this.getView().setLoading(true);            
 5                 store.sync({
 6                     success: function(batch, options) {
 7                          this.doEndEdit();
 8                          this.getContext().onStoreSyncComplete();
 9                          this.getView().setLoading(false);
10                     },
11                     failure: function(batch, options) {
12                         var msg = options.batch.proxy.reader.rawData.message;
13                         Ext.Msg.alert('提示', msg);
14                         this.getView().setLoading(false);
15                     },
16                     scope: this
17                 });
18             }
19             else {
20                 this.doEndEdit();
21             }
22         }
23     }

 

posted on 2013-11-25 14:41  看天空的星星  阅读(404)  评论(0编辑  收藏  举报

导航