2015-05-07 51 views
3

連鎖賣場GlobalStore我想用在鏈接到全局存儲, 商店,但推出後我給了JS警告:EXTJS在視圖模型

Ext.data.Store created with no model 

,我看不到任何數據。

這裏是我的代碼:

全球UserStore

Ext.define('App.store.UserStore',{ 
extend  : 'App.store.AjaxReadyStore', 
requires : ['App.model.UserModel'], 
model  : 'App.model.UserModel', 
autoLoad : false, 
id   : 'UserStore', 
alias  : 'store.UserStore', 


constructor : function() { 
    this.callParent(arguments); 
    this.proxy.api= { 
     create : 'api/v1/users', 
     read : 'api/v1/users', 
     update : 'api/v1/users', 
     destroy : 'api/v1/users' 
    }; 
    this.readAndLoad(); 
} 
}); 

視圖模型

Ext.define('App.view.tasktemplate.TaskTemplateModel', { 
    extend : 'Ext.app.ViewModel', 
    alias : 'viewmodel.tasktemplate', 
    stores : { 
     owner: { 
      source : 'UserStore' 
     } 
    } 
}); 

查看

Ext.define('App.view.tasktemplate.TaskTemplateOwnerList',{ 
    extend : 'App.view.pool.grid.GridWithAction', 
    xtype : 'tasktemplateownerlist', 
    store: { 
     bind : '{owner}' 
    }, 
}); 
+0

plus1 - 這很有趣。 – Yellen

回答

0

更改您的視圖代碼到這一點 -

Ext.define('App.view.tasktemplate.TaskTemplateOwnerList',{ 
     extend : 'App.view.pool.grid.GridWithAction', 
     xtype : 'tasktemplateownerlist', 
     bind: { 
      store : '{owner}' 
     } 
    }); 

存儲綁定:

bind: { 
    store : '{owner}' 
} 

當你做

store: { 
     bind : '{owner}' 
    } 

您的視圖中它實際上是有趣的 - 該StoreManager做一個帶有存儲配置值的查找,通常是e xpecting一個字符串或字符串數​​組(存儲名稱),但它看到它不是一個字符串,而是一個對象,因此它創建一個'Ext.data.Store'的實例,將{bind:'{owner}'}作爲config - > so你實際上得到了一個沒有關聯模型的Store類的實例。 店面: