Extjs 6使用Ext.define定义一个链式存储

时间:2016-11-17 13:52:29

标签: extjs extjs4 extjs6 extjs6-classic

可以使用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,但似乎代码不完整。

谢谢

1 个答案:

答案 0 :(得分:4)

  

可以使用Ext.define语句定义链式存储吗?

肯定是的。但source configchained 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'
    }]
});

查看这个小提琴示例https://fiddle.sencha.com/#view/editor&fiddle/1kk4