【问题标题】:How to fire onSelect of a extjs 3.4 combo when loading a Store?加载商店时如何触发 extjs 3.4 组合的 onSelect?
【发布时间】:2014-03-03 00:40:59
【问题描述】:

这是我的代码 -

Store = new Ext.data.JsonStore({
url: 'url',
totalProperty: 'count',
id: 'Code',
root: 'rows',
autoLoad: true,
triggerAction: 'all',
fields: ['title', 'description'],
listeners: {
    load: {
        fn: function (store) {
            Ext.getCmp('Combo').setValue(store.getAt('1').get('title'));
            Ext.getCmp('Combo').fireEvent('select');
        }
    }
}
}
);

xtype: 'combo',
id: 'Combo',
store: Store,
fieldLabel: 'title',
displayField: 'title',
valueField: 'title',
typeAhead: false,
editable: false,
allowBlank: false,
mode: 'local',
emptyText: 'Select...',
forceSelection: true,
triggerAction: 'all',
name: 'DefaultCombo',
selectOnFocus: true,
width: 150
, onSelect: function () {
alert('message');
}

在此处设置组合框值,但 onSelect 未在此处触发。 我使用的是 3.4 版本

【问题讨论】:

    标签: javascript extjs extjs3


    【解决方案1】:

    我在fiddle 中对此进行了测试。 onSelect 函数似乎只在进行选择时触发。但是,如果您为 select 事件添加侦听器,而不是在任何一种情况下都会触发。

    listeners: {
                select:function(){
                    console.log('Select Event Fired!')
                }
            },
    

    【讨论】:

    • 嗨,@Weeksdev 我尝试了您发布的fiddle,但它在 Google chrome 上不起作用。它在 Google Chrome 上适合您吗?
    • 谢谢!只是认为它只发生在其中一台机器的 chrome 上。
    • 控制台中没有错误。它只能在一个桌面上重复。
    • @leoh 网络选项卡中是否有任何内容被丢弃或不返回 200 ok?在该机器上重新安装 chrome 是否可以解决问题?
    猜你喜欢
    • 2013-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-21
    • 2013-01-31
    • 2016-06-24
    • 1970-01-01
    相关资源
    最近更新 更多