可以使用Ext.define语句定义链式存储吗?我尝试了以下代码,但我收到了错误:
Ext.define('MyProject.store.RelFiltered', {
extend: 'Ext.data.ChainedStore',
source:'MyProject.store.Rel',
alias: 'store.releasesFiltered'
});
我收到的错误是:
Ext.data.ChainedStore.applySource(): Invalid source "MyProject.store.Rel" specified for Ext.data.ChainedStore
和
Ext.mixin.Bindable.applyBind(): Cannot use bind config without a viewModel
我从this帖子中获得了idee,但似乎代码不完整。
谢谢
答案 0 :(得分:4)
可以使用Ext.define语句定义链式存储吗?
肯定是的。但source config的chained store表示它应该是商店实例或现有商店的ID。
所以代码看起来像这样:
Ext.define('MyApp.store.MyChainedStore', {
extend: 'Ext.data.ChainedStore',
storeId: 'MyChainedStore',
//source using storeID
source: 'OriginalStore'
});
Ext.define('MyApp.store.OriginalStore', {
extend: 'Ext.data.Store',
requires: [
'Ext.data.field.Field'
],
storeId: 'OriginalStore',
data: [{
id: 1,
name: 'commodi'
}],
fields: [{
name: 'id'
}, {
name: 'name'
}]
});