1. #1
    Ext JS Premium Member
    Join Date
    Nov 2008
    Location
    Warsaw area, Poland
    Posts
    64
    Vote Rating
    1
    nightwatch is on a distinguished road

      0  

    Default Answered: ComboBox autocomplete with local mode - substring search instead of prefix match

    Answered: ComboBox autocomplete with local mode - substring search instead of prefix match


    Hi, I have a combobox configured for autocompletion in queryMode: "local":

    Code:
    editor: {xtype: 'combobox', store: dataSrcSt, valueField: 'Id', displayField: 'Description', allowBlank: false, queryMode: 'local', typeAhead: true, minChars: 2}
    And the autocomplete seems to work - it matches a correct entry if a prefix of the display value is entered. But what should I do to filter the entries by matching a substring anywhere in the display value ( 'displayValue like *typedText*', not 'like typedText*')

    ExtJS 4.1

    Thanks
    RG

  2. You can try this:
    PHP Code:
    Ext.onReady(function() {

    var 
    simpleCombo Ext.create('Ext.form.field.ComboBox', {
      
    fieldLabel'Select a single state',
      
    displayField'name',
      
    valueField'abbr',
      
    width320,
      
    labelWidth130,
      
    queryMode'local',
      
    typeAheadtrue,
      
    minChars2,
      
    name'agentDownline',
      
    store: new Ext.data.SimpleStore({
          
    fields: ['abbr''name''slogan'],
          
    data: [
            [
    'VA''Virginia',      'Mother of States'],
            [
    'WA''Washington',    'Green Tree State'],
            [
    'WV''West Virginia''Mountain State'],
            [
    'WI''Wisconsin',     'America\'s Dairyland'], 
            [
    'WY''Wyoming',       'Like No Place on Earth']
          ]
      }),
      
    listeners: {
        
    buffer50,
        
    change: function() {
          var 
    store this.store;
          
    //store.suspendEvents();
          
    store.clearFilter();
          
    //store.resumeEvents();
          
    store.filter({
              
    property'name',
              
    anyMatchtrue,
              
    value   this.getValue()
          });
        }
      }
    });

    Ext.create("Ext.Window", {
        
    itemssimpleCombo
    }).show(); 
    Is that what you are looking for?

  3. #2
    Sencha User
    Join Date
    Oct 2011
    Location
    Ukraine
    Posts
    148
    Vote Rating
    5
    Answers
    10
    Romick is on a distinguished road

      0  

    Default Hii

    Hii


    You can try this:
    PHP Code:
    Ext.onReady(function() {

    var 
    simpleCombo Ext.create('Ext.form.field.ComboBox', {
      
    fieldLabel'Select a single state',
      
    displayField'name',
      
    valueField'abbr',
      
    width320,
      
    labelWidth130,
      
    queryMode'local',
      
    typeAheadtrue,
      
    minChars2,
      
    name'agentDownline',
      
    store: new Ext.data.SimpleStore({
          
    fields: ['abbr''name''slogan'],
          
    data: [
            [
    'VA''Virginia',      'Mother of States'],
            [
    'WA''Washington',    'Green Tree State'],
            [
    'WV''West Virginia''Mountain State'],
            [
    'WI''Wisconsin',     'America\'s Dairyland'], 
            [
    'WY''Wyoming',       'Like No Place on Earth']
          ]
      }),
      
    listeners: {
        
    buffer50,
        
    change: function() {
          var 
    store this.store;
          
    //store.suspendEvents();
          
    store.clearFilter();
          
    //store.resumeEvents();
          
    store.filter({
              
    property'name',
              
    anyMatchtrue,
              
    value   this.getValue()
          });
        }
      }
    });

    Ext.create("Ext.Window", {
        
    itemssimpleCombo
    }).show(); 
    Is that what you are looking for?

  4. #3
    Ext JS Premium Member
    Join Date
    Nov 2008
    Location
    Warsaw area, Poland
    Posts
    64
    Vote Rating
    1
    nightwatch is on a distinguished road

      1  

    Default


    Yes, that's the solution. Thanks!