1. #1
    Sencha User
    Join Date
    Dec 2008
    Posts
    36
    Answers
    1
    Vote Rating
    0
    rondinos is on a distinguished road

      0  

    Default Answered: Combobox autocomplete to search the whole string in local mode

    Answered: Combobox autocomplete to search the whole string in local mode


    Hello,

    I have a combobox in local mode with a list of names that could be either (FirstName LastName) or (LastName FirstName). I noticed that the autocomplete only searches strings that start with "string" instead of contains "string". Kind of '%string%' instead of 'string%' in mysql. Is there a way to do this in a local mode ?

  2. Try this:
    Code:
    Ext.onReady(function(){
        var combo = Ext.create('Ext.form.field.ComboBox', {
            fieldLabel: 'Demo',
            renderTo: Ext.getBody(),
            multiSelect: false,
            displayField: 'name',
            width: 220,
            labelWidth: 70,
            store: {
                fields: ['name'],
                data: [{
                    name: 'John Smith'
                },{
                    name: 'Albert Einstein'
                },{
                    name: 'Thomas Edison'
                },{
                    name: 'John Deer'
                }]
            },
            queryMode: 'local',
            listeners: {
                beforequery: function(qe){
                    qe.query = new RegExp(qe.query, 'i');
                    qe.forceAll = true;
                }   
            }
        });
    
    
    });

  3. #2
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    Try this:
    Code:
    Ext.onReady(function(){
        var combo = Ext.create('Ext.form.field.ComboBox', {
            fieldLabel: 'Demo',
            renderTo: Ext.getBody(),
            multiSelect: false,
            displayField: 'name',
            width: 220,
            labelWidth: 70,
            store: {
                fields: ['name'],
                data: [{
                    name: 'John Smith'
                },{
                    name: 'Albert Einstein'
                },{
                    name: 'Thomas Edison'
                },{
                    name: 'John Deer'
                }]
            },
            queryMode: 'local',
            listeners: {
                beforequery: function(qe){
                    qe.query = new RegExp(qe.query, 'i');
                    qe.forceAll = true;
                }   
            }
        });
    
    
    });

  4. #3
    Sencha User
    Join Date
    Dec 2008
    Posts
    36
    Answers
    1
    Vote Rating
    0
    rondinos is on a distinguished road

      0  

    Default


    This worked like a charm!!!
    Thank you so much

Thread Participants: 1

Tags for this Thread