【问题标题】:bind a store to a list filter in extjs 5将商店绑定到 extjs 5 中的列表过滤器
【发布时间】:2015-09-09 10:24:10
【问题描述】:

我正在使用 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'
        }

过滤器有效,但它不显示绑定存储中的数据,而是从网格的存储中创建它自己的数据

我错过了什么吗?

【问题讨论】:

    标签: javascript extjs binding viewmodel store


    【解决方案1】:

    在过滤器中传递这些属性并试试这个:

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

    【讨论】:

    • 我知道一个简单过滤器的配置,我在这里尝试做的是使用 viewModel 中的绑定存储
    【解决方案2】:

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

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

    【讨论】:

      【解决方案3】:

      另一种方法,对我有用

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-11-19
        • 2023-03-20
        • 2012-09-19
        • 1970-01-01
        • 2018-06-30
        • 2021-08-19
        相关资源
        最近更新 更多