Results 1 to 3 of 3

Thread: Extend ComboBox with default "Other..." option

  1. #1
    Sencha User
    Join Date
    Sep 2010
    Location
    Belgium
    Posts
    29

    Default Extend ComboBox with default "Other..." option

    Hi All,

    I want to extend the Ext.form.ComboBox with a default "Other..." item (preferrably last in the list of items) and bind an event to this item when selected.
    The ComboBox is filled with data from an Ext.data.JsonStore.
    What is the best way to approach this (if possible)?

    Thanks a lot!
    Sam

  2. #2
    Sencha User
    Join Date
    Sep 2010
    Location
    Belgium
    Posts
    29

    Default

    Should I look into adding an item to the JsonStore or is it better to add an aditional item when rendering the element?

  3. #3
    Sencha User
    Join Date
    Sep 2010
    Location
    Belgium
    Posts
    29

    Default

    In case someone can use this, I managed to do this with:

    Code:
    Ext.onReady(function() {
        ux.OtherComboBox = Ext.extend(Ext.form.ComboBox, {
            otherText: 'Other...',
            initComponent: function()
            {
                var otherRecord = new this.store.recordType({
                    name: this.otherText
                });
                this.store.addListener('load', function() {
                    this.insert(this.getCount(), otherRecord);
                });
                ux.OtherComboBox.superclass.initComponent.call(this, arguments);
                this.addListener('select', function(combo, record, index) {
                    if (otherRecord === record) {
                        combo.fireEvent('selectOther');
                    }
                });
            }
        });
        Ext.reg('othercombo', ux.OtherComboBox);
    });

Similar Threads

  1. Replies: 6
    Last Post: 2 Sep 2009, 3:31 AM
  2. Replies: 5
    Last Post: 5 Jun 2009, 10:44 AM
  3. Empty option in ComboBox displays " "
    By dbnetink in forum Ext 2.x: Help & Discussion
    Replies: 10
    Last Post: 22 Sep 2008, 8:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •