0

I wrote the following implementation of combo box with dynamic data upload.

Code

Loyalty.tools.DictionaryComboBox = Ext.extend(Ext.form.ComboBox,

 {
    defaultConfig:{

        defaults:{
            labelWidth:150
        },
        displayField:'value',
        valueField:'key',
        forceSelection:true,
        mode:'local',
        typeAhead: true,
        triggerAction: 'all',
        selectOnFocus:true
    },

    constructor:function (config) {
        Ext.apply(config, this.defaultConfig);
        config['store'] = new Ext.data.Store({
            fields:['key', 'value', 'description'],
            proxy:{
                type:'ajax',
                url:config.dictionaryPath + '/' + config.dictionaryName
            }
        });
        Loyalty.tools.DictionaryComboBox.superclass.constructor.call(this, config);
    }

}

 );

and I use it the following way

            new Loyalty.tools.DictionaryComboBox({
                fieldLabel: Loyalty.messages['company.grid.filter.forma'],
                dictionaryPath: config.dictionaryPath,
                dictionaryName: 'forma',
                name: 'forma',
                id:'forma',
                allowBlank:true,
                labelWidth:config.labelWidth
            }),

I have the two problems 1) How can I get the list data when combo box is loading( rather than on the first click) 2) and if I'm putting a key in the combo box so that it immediately display the desired value?

2 Answers 2

1

1) how are you loading the store. I think you need to add autoLoad: true like so

fields:['key', 'value', 'description'],
autoLoad: true,

2) are you asking how do i select the combo box

var mycombo = Ext.getCmp('mycombo');
mycombo.setValue(id);
Sign up to request clarification or add additional context in comments.

3 Comments

neither one nor the other did not work .... 1) The list is really loaded at the beginning, but then is duplicateloading when you click on it 2) does not bear a more accurate value is set, but not displayed. I think all of this as something to do with the fact that the first load, as if ignored
try queryMode : 'local' instead of mode : 'local'
Hi. i decided my problem. Unfortunately I had to use not "right" metod
1

i decided my problem. Unfortunately I had to use not "right" metod

Loyalty.tools.DictionaryComboBox = Ext.extend(Ext.form.ComboBox,
    {
        defaultConfig:{

            defaults:{
                labelWidth:150
            },
            displayField:'value',
            valueField:'key',
            forceSelection:true,
            queryMode: 'local',
            typeAhead: true,
            triggerAction: 'all',
            selectOnFocus:true
        },

        constructor:function (config) {
            Ext.apply(config, this.defaultConfig);
            var isStoreProvided = (config['store'] == undefined);
            if (isStoreProvided) {
                var el = this;


   config['store'] = new Ext.data.Store({
                fields:['key', 'value', 'description'],
                autoLoad:true,
                proxy:{
                    type:'ajax',
                    url:config.dictionaryPath + '/' + config.dictionaryName
                },
                listeners: {
                    'load': function() {
                        if (config['initialValue'] != undefined) {
                            el.setValue(config['initialValue']);
                            config['initialValue'] = undefined;
                        }
                    }
                }
            });
        }
        Loyalty.tools.DictionaryComboBox.superclass.constructor.call(this, config);
    }

}

);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.