1. #1
    Ext JS Premium Member
    Join Date
    Dec 2011
    Posts
    29
    Vote Rating
    0
    seema is on a distinguished road

      0  

    Default combo box - select a value on key press

    combo box - select a value on key press


    Hi,

    I'm looking for a very obvious behavior of HTML select in ExtJs 4 combo box.
    If I press in a key then the control should move to combo box value starting from that key. How can I achieve this.

    I have tried
    Code:
    queryMode:'local'
    which is doing same kind of thing but its allowing editing in combo box. I dont want to make it editable.

    Here is code for my combo box

    Code:
    {
     xtype: 'combobox',
     fieldLabel: 'Choose Country',
     store: states,
     queryMode: 'local',
     hideTrigger:true,             
     displayField: 'name',
     valueField: 'abbr'             
    }
    Please suggest how to achieve this

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,651
    Vote Rating
    899
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    For this you'd have to set the editable config to false so that the person could not type in the input. You'd have to capture the keydown event and then scroll to the first/best match.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,626
    Vote Rating
    332
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    Code:
    Ext.create('Ext.form.field.ComboBox', {
        editable: false,
        enableKeyEvents: true,
        renderTo: Ext.getBody(),
        store: ['Volvo', 'Saab', 'Fiat', 'Audi'],
    
        listeners: {
            keyup: function(combo, event) {
                var key = String.fromCharCode(event.getKey()),
                    boundList = combo.getPicker(),
                    store = boundList.getStore(),
                    record = store.findRecord(combo.displayField, key);
    
                if (record) {
                    boundList.highlightItem(boundList.getNode(record));
                }
            }
        }
    });

  4. #4
    Ext JS Premium Member
    Join Date
    Dec 2011
    Posts
    29
    Vote Rating
    0
    seema is on a distinguished road

      0  

    Default Its working fine

    Its working fine


    Hi,

    Thanks!!

    Its working fine.


    Thanks a lot.

Thread Participants: 2

Tags for this Thread