在extjs 5中将存储绑定到列表过滤器

bind a store to a list filter in extjs 5

本文关键字:绑定 列表 过滤器 存储 extjs      更新时间:2023-09-26

我在使用sencha CMD布局(mvvm)的web应用程序上使用extjs 5,并想在我的视图网格中绑定一个存储(用于标签)来过滤列表viewModel存储定义为:

 stores: {
    labelContacts: {
        model: 'myapp.model.label.Contact'
        , autoLoad: true
    } // end contact store
 } // end stores

和我的列表过滤器代码在视图网格

filter: {
                type: 'list',
                bind: {store: '{labelContacts}'}
                labelField: 'DisplayValue',
                valueField: 'keyId'
        }

过滤器工作,但它不显示绑定存储的数据,而是从网格的存储

创建自己的数据

我错过了什么吗?

在过滤器中传递这些属性并尝试如下:

        type: 'list',
        store: store, // your store
        labelField: 'DisplayValue', // Your displayValue
        valueField: 'keyId', // Key Id on which you want to add filter          

我找到了一个解决方法来获得绑定商店,但我对解决方案不满意,因为它不是一个真正优雅的解决方案,并将很高兴听到任何建议我的解决方案是将存储更改为:

filter: {
    type: 'list',
    store:new myapp.view.main.MainModel().getStore('labelContacts'),
    labelField: 'label',
    valueField: 'id'
}

另一种方法,适合我

        {
            text: 'Yes/No',
            dataIndex: 'accompanied',
            filter: {
                type: 'list',
            },
            listeners: {
                boxready: function (_this, width, height, eOpts) {
                    _this.filter.store = _this.lookupViewModel().getStore('dicYesNo');
                }
            }
        }