Extjs 4 combobox default value

后端 未结 9 1501
时光取名叫无心
时光取名叫无心 2020-12-06 04:41

I\'m migrating my application from ExtJs 3 to 4 version. I have several comboboxes at my formPanel, and previously I\'ve used hiddenName and all that stuff to submit valueFi

9条回答
  •  太阳男子
    2020-12-06 05:03

    I bet this has to do with the time you (asynchronously) load the combobox, and the time you set the value of the combobox. To overcome this problem, simply do this:

    Ext.define('idNamePair', {
        extend: 'Ext.data.Model',
        fields: [
            {name: 'id', type: 'string'},
            {name: 'name',  type: 'string'}
        ]
    });
    
    var dirValuesStore = new Ext.data.Store({
        model: 'idNamePair',
        proxy: {
            type: 'ajax',
            url: '../filtervalues.json',
            reader: {
                type: 'json',
                root: 'dir'
            }
        },
        autoLoad: false // set autoloading to false
    });
    

    Autoloading of the store is off. Now, after you have placed your ComboBox at a certain place -- using the code in your starting post -- you simply load the store manually: dirValuesStore.load();.

    That is probably after the config Ext.apply(this, {items: [..., {xtype: 'combo', ...}, ...]}) in some component's initComponent().

提交回复
热议问题