Results 1 to 7 of 7

Thread: [Solved] Combobox with forceSelection does not select

  1. #1
    Sencha User
    Join Date
    Jun 2009
    Posts
    32

    Thumbs up [Solved] Combobox with forceSelection does not select

    I have ComboBox to select numbers 1 to 60 with forceSelection and typeAhead.
    If I type in e.g. 42 and click on the next textbox the Combobox remains empty.

    If I click on 42 in the list or use tab to get in the next field it works but not if you click after typing. It also works if I disable forceSelection but I like to have forceSelection...

    Couldn't find a fix for this here...

    Code:
    var combo = new Ext.form.ComboBox({
        store: pagerNumbersStore,
        valueField: 'name',
        displayField: 'name',
        id: 'pager_number',
        typeAhead: true,
        mode: 'local',
        triggerAction: 'all',
        value: pagerNumber,
        forceSelection: true,
        maskRe: /[0-9]/,
        renderTo: Ext.get('pager_number_div')
    });
    ExtJs version is 3.0 RC2.
    Last edited by PiExt; 4 Aug 2009 at 4:44 AM. Reason: solved

  2. #2
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    Seems a stunningly pointless ComboBox. Type "42", and it selects "42"?

  3. #3
    Sencha User
    Join Date
    Jun 2009
    Posts
    32

    Default

    Not really because 42 is just a short name for a very long number and not all numbers are available all the time. That's why I like to have forceSelection.

    But anyway beside of what is in the combobox, it is really unexpected if a valid value is not excepted just because I click with the mouse instead of using the tab key.

  4. #4
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    I think you have to select the entry. It must recieve some event to say "yes, select that".

    So Tabbing selects it.

    In reality going backwards and forwards between keyboard and mouse is very annoying for users. If you are writing an application, the users will learn to use the keyboard, and clatter through it without taking their hands off the keyboard.

  5. #5
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    On second thoughts, I think you have a point, and it's a bug.

    Try this override:

    Code:
    Ext.override(Ext.form.ComboBox, {
        beforeBlur : function(){
            var val = this.getRawValue();
            var rec = this.findRecord(this.displayField, val);
            if(!rec && this.forceSelection){
                if(val.length > 0 && val != this.emptyText){
                   this.el.dom.value = Ext.isDefined(this.lastSelectionText) ? this.lastSelectionText : '';
                    this.applyEmptyText();
                }else{
                    this.clearValue();
                }
            }else{
                if(rec){
                    val = rec.get(this.valueField || this.displayField);
                }
                this.setValue(val);
            }
        }
    });

  6. #6
    Sencha User
    Join Date
    Jun 2009
    Posts
    32

    Thumbs up

    This problem is reality. I am here because I have several user how have reported this problem.

    Your override fixes the problem. Thanks a lot!

  7. #7
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

Posting Permissions

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