2013-12-13 59 views
0
Ext.define('RouteSeqModel', { 
    extend: 'Ext.data.Model', 
    fields: [{name: '_id', type: 'number'}, {name: 'Route_Seq' , type: 'int'},'Location_Name','Route_LocationID','Route_ID'] 
}); 

var RouteSeqStore = Ext.create('Ext.data.JsonStore', { 
    model: 'RouteSeqModel', 
    storeId: 'RouteSeqStore', 
    autoLoad: false, 
    sorters: [{ 
       property: 'Route_Seq', 
       direction: 'ASC' 
      }], 
    proxy: { 
     type: 'ajax', 
     url: 'get-routeseq.php', 
     api: { 
       create: 'insert-routeseq.php', 
       //read: 'http://visual04/ModuleGestion/php/Pays.php?action=read', 
       update: 'update-routeseq.php', 
       //destroy: 'http://visual04/ModuleGestion/php/Pays.php?action=destroy' 
      }, 
     actionMethods: 'POST', 
     baseParams: { 
       _id : 0, 
      }, 
     reader: { 
      type: 'json', 
      idProperty: '_id' 
     }, 
     writer: { 
      type: 'json', 
      id: '_id' 

     } 
    } 
}); 
RouteSeqStore.sync({ 

       success: function(batch) { 
          //var button = Ext.getCmp('BtnRouteSeqRefresh'); 
          //button.fireEvent('click', button); //need at here , if not too fast refresh will get the old data 
          grid.setLoading(false); 
          Ext.MessageBox.show({ 
           title: "Information", 
           msg: batch.operations[0].request.scope.reader.jsonData["message"], 
           icon: Ext.MessageBox.INFO, 
           buttons: Ext.MessageBox.OK, 
           fn: function(buttonId) { 
            if (buttonId === "ok") { 
             //load store at here 
            } 
           } 
          }); 
       }, 
        failure: function(batch){ 
         //var button = Ext.getCmp('BtnRouteSeqRefresh'); 
         //button.fireEvent('click', button); //need at here , if not too fast refresh will get the old data 
         grid.setLoading(false); 
         RouteSeqStore.rejectChanges(); 
            Ext.MessageBox.show({ 
           title: "Error", 
           msg: batch.operations[0].request.scope.reader.jsonData["message"], 
           icon: Ext.MessageBox.ERROR, 
           buttons: Ext.MessageBox.OK, 
           fn: function(buttonId) { 
            if (buttonId === "ok") { 
             //load store at here 
            } 
           } 
        }); 

       } 

      }); 

每當稱爲.SYNC功能會自動加載get-routeseq.php數據存儲,
是有按下OK按鈕只能加載數據存儲後的任何方式(後按OK只調用get-routeseq.php)?
我的autoLoad爲false,但仍自動加載數據存儲。store.sync後按下確定按鈕只有重裝店面

回答

0

我認爲你應該使用type: 'rest'並避免代理中的URL配置。 事情是這樣的:

var RouteSeqStore = Ext.create('Ext.data.JsonStore', { 
    model: 'RouteSeqModel', 
    storeId: 'RouteSeqStore', 
    autoLoad: false, 
    sorters: [{ 
     property: 'Route_Seq', 
     direction: 'ASC' 
    }], 
    proxy: { 
     type: 'rest', 
     api: { 
      create: 'insert-routeseq.php', 
      read: 'get-routeseq.php', 
      update: 'update-routeseq.php', 
      //destroy: 'http://visual04/ModuleGestion/php/Pays.php?action=destroy' 
     }, 
     actionMethods: 'POST', 
     baseParams: { 
      _id : 0, 
     }, 
     reader: { 
      type: 'json', 
      idProperty: '_id' 
     }, 
     writer: { 
      type: 'json', 
      id: '_id' 

     } 
    } 
}); 

如果你只想負載存儲,使用RouteSeqStore.load()。在商店進行更改後,請使用RouteSeqStore.sync()