【问题标题】:ExtJS Bind Filter and select default value on child combo boxExtJS 绑定过滤器并在子组合框上选择默认值
【发布时间】:2018-08-06 01:34:31
【问题描述】:

我正在尝试创建两个组合框。第一个显示国家名称,第二个显示省/州。这个想法是根据第一个组合的选择过滤第二个组合,并将“VisitingCountryProvince”的值作为默认选择。 下面代码的问题是,它没有根据第一个组合框选择默认值。如果我删除绑定过滤器,第二个组合框会显示正确的“VisitingCountryProvince”值。

有什么想法吗?

{
    xtype: 'fieldset',
    title: 'Visiting Country',
    layout: 'anchor',
    anchor: '-10',
    collapsible: false,
    defaults: {
        xtype: 'combo',
        labelStyle: 'font-weight: bold;',
        flex: 1,
        anchor: '0',
        editable: false,
        forceSelection: true,
        allowBlank: false,
        emptyText: 'Select...',
        queryMode: 'local',
    },
    items: [{
        name: 'VisitingCountry',
        fieldLabel: 'Main',
        reference: 'visitingCountryFieldRef',
        publishes: 'value',
        store: {
            type: 'arraydropdownstore'
        },
        valueField: 'value',
        displayField: 'value'
    }, {
        name: 'VisitingCountryProvince',
        fieldLabel: 'Sub',
        store: {
            type: 'array',
            fields: ['value', 'countryName']
        },
        bind: {
            filters: {
                property: 'countryName',
                value: '{visitingCountryFieldRef.value}'
            }
        },
        valueField: 'value',
        displayField: 'value'
    }]
},

我能找到的最接近问题的答案在这里,How to use combo "publishes" value & bindings to filter store on another combo

我刚刚发现,我可以进行过滤或选择默认值,而不是两者兼而有之。如何从过滤后的列表中过滤和绑定默认值?

【问题讨论】:

    标签: extjs sencha-cmd


    【解决方案1】:

    您需要在第一个组合框的“选择”事件处理程序中编写过滤第二个组合存储值的逻辑。

    {
            name: 'VisitingCountry',
            fieldLabel: 'Main',
            reference: 'visitingCountryFieldRef',
            publishes: 'value',
            store: {
                type: 'arraydropdownstore'
            },
            valueField: 'value',
            displayField: 'value',
            listeners:{
                 select:function(){
                    //Access the second[bound to second combobox]store and apply the 
                    //filter, Also there are arguments for select event handler, for this 
                    //Please refer docs.sencha.com for extjs version you are using.
                 }
            }
    }
    

    【讨论】:

      猜你喜欢
      • 2011-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-30
      • 1970-01-01
      • 2012-11-16
      • 2017-12-03
      相关资源
      最近更新 更多