组合框中的默认选定值

我有一个组合框,其中有两种笔记本电脑,东芝和hp。加载时,选择默认值为空。我想将默认的选择值设为东芝,以便最初选择它。如在HTML中“选中”。有什么帮助吗?

laptops = Ext.create('Ext.data.Store', {
        fields: ['abbr','value', 'name'],
        data : [
            {"abbr":"tosh","value":"toshibatypes", "name":"Toshiba"},
            {"abbr":"hp","value":"hptypes", "name":"HP"}
        ]
    });



    toshibatypes = Ext.create('Ext.form.Panel', {
            xtype: 'radiogroup',
            defaultType: 'radio', 
            layout: 'hbox',
            border:false,
            id: 'toshiba',
            width:'100%',

            items: [ 
            {
                checked: true,
                boxLabel: 'Toshiba 1',
                name: 'toshibas',
                inputValue: 'toshiba1',
                xtype:'radiofield'
            }, 
            {
                boxLabel: 'Toshiba 2',
                name: 'toshibas',
                inputValue: 'toshiba2',
                xtype:'radiofield'
            }
        ]
    });



    hptypes = Ext.create('Ext.form.Panel', {
            xtype: 'radiogroup',
            defaultType: 'radio', 
            layout: 'hbox',
            border:false,
            id: 'hp',
            width:'100%',

            items: [ 
            {
                checked: true,
                boxLabel: 'HP 1',
                name: 'hps',
                inputValue: 'hp1',
                xtype:'radiofield'
            }, 

            {
                boxLabel: 'HP 2',
                name: 'hps',
                inputValue: 'hp2',
                xtype:'radiofield'
            }]
    });



        laptoptypes = Ext.create('Ext.form.ComboBox', {
            store: laptops,
            queryMode: 'local',
            displayField: 'name',
            valueField: 'abbr',
            editable:false,
            width: 100,
            onchange:onSelectChange(this),
        });
塔拉巴斯

只需设置valuecombobox对应于从商店的值。因此,如果设置valueField'abbr''abbr'则可以使用存储的值之一

laptoptypes = Ext.create('Ext.form.ComboBox', {
    store: laptops,
    queryMode: 'local',
    displayField: 'name',
    valueField: 'abbr',
    value: 'tosh',
    editable:false,
    width: 100,
    onchange:onSelectChange(this),
});

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章