1

I'm attemtping to create a custom ComboBox control. The control will have a button on either side of the ComboBox itself, something like this:

[<-]   [ --------------- V ]    [->]

These buttons will be "next" and "previous" which will allow the user to quickly toggle between options in the dropdown (moving down and up respectively).

I've tried overriding the defaultAutoCreate config of the ComboBox, but I'm getting some odd behavior. Here's what I've tried so far: (this is all inside of a custom class extending ComboBox)

initComponent: function () {

    // default ComboBox structure
    var comboStructure = { 
        tag: 'span',
        children: [
            { tag: 'a', cls: 'nav prev', html: 'Previous' },
            { tag: 'input', type: 'text', size: '24', autocomplete: 'off' },
            { tag: 'a', cls: 'nav next', html: 'Next' }
        ]
    };

    console.log(comboStructure);

    var config = {
        triggerAction: 'all',
        lazyRender: true,
        mode: 'local',
        store: new Ext.data.ArrayStore({
            fields: [
                'myId',
                'displayText'
            ],
            data: [[1, 'Banner #1'], [2, 'Banner #2']]
        }),
        valueField: 'myId',
        displayField: 'displayText',
        defaultAutoCreate: comboStructure
    };

    Ext.apply(this, config);

    IbwUi.controls.PreviewBannerSelectDropdown.superclass.initComponent(this);

}

The 2nd "child" of the comboStructure is actually the default value that gets initialized for ComboBox, I looked at the source code. The code works without error, but there's some odd behavior with the rendering of the combo itself, see here:

Weird DOM display

Any ideas on how to add my custom elements around the ComboBox when it renders?

1 Answer 1

1

Don't do it like this. Instead put all three components into a container class that implements the logic you need.

Sign up to request clarification or add additional context in comments.

1 Comment

I could do that, and it's probably easier, but I'm still wondering why this solution doesn't work. I noticed that the "arrow" for the ComboBox doesn't appear to be a part of the default structure...that's why its getting added afterwards.

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.