Sencha Touch - 代理



代理的基類是 Ext.data.proxy.Proxy。模型和儲存會使用代理來處理模型資料的載入和儲存。

有兩種型別的代理 −

  • 客戶端代理
  • 伺服器代理

客戶端代理

客戶端代理包括記憶體和本地儲存,它們會使用 HTML5 本地儲存。

伺服器代理

伺服器代理會使用 Ajax、Json 資料以及 Rest 服務來處理來自遠端伺服器的資料。代理可以寫入模型並在任意位置儲存。

Ext.create('Ext.data.Store', {
   model: 'StudentDataModel', proxy : {
      type : 'rest', actionMethods : {
         read : 'POST'  
         // Get or Post type based on requirement
      },
      url : 'restUrlPathOrJsonFilePath', 
      // here we have to include the rest URL path 
      which fetches data from database or Json file path where the data is stored reader: {
         type : 'json',  
         // the type of data which is fetched is of JSON type
         root : 'data'
      },
   }
});
sencha_touch_data.htm
廣告
© . All rights reserved.