1. #1
    Sencha User
    Join Date
    Jan 2008
    Posts
    16
    Vote Rating
    0
    Timido is on a distinguished road

      0  

    Question ComboBox autocomplete: excluding some characters from triggering remote search

    ComboBox autocomplete: excluding some characters from triggering remote search


    Hello!

    I have a combobox with autocomplete function turned on to query against a remote URL.

    It works just fine, and I use it to let the user select from a list of TAGS (yes, like those used in blogs).

    I would like to have some characters excluded from triggering a remote search.

    For example, if I type "av", the remote search should be triggered.
    Then say I select the word "aviation" from the list.
    Then if I type a single comma "," after aviation because I want to enter a new word, the remote search should not be triggered.

    That is, typing just a single comma or a single whitespace should not trigger any search.
    Still I want to trigger the search when I type even one single alphabetic character.

    Is that possible?

    This is my code:


    Code:
    var search = new Ext.form.ComboBox({
                    store: store,
                    displayField:'name',
                    typeAhead: false,
                    minChars: 1,
                    loadingText: 'Searching...',
                    width: 570,
                    pageSize:0,
                    hideTrigger:true,
                    tpl: resultTpl,
                    applyTo: 'search',
                    itemSelector: 'div.search-item'
                });
    I tried with maskRe but looks like it's the wrong way.
    Thank you!

  2. #2
    Sencha User
    Join Date
    Jan 2008
    Posts
    16
    Vote Rating
    0
    Timido is on a distinguished road

      0  

    Default


    Guess I found the way

    Anyway, any better idea is welcome of course


    Code:
    listeners: {
    
          'beforequery': function (queryEvent) {
    
                 value = queryEvent.combo.getValue();
                 re = /.*[,\s]+$/;
        
                 if (value.match(re)) {
                     return false;
                 }
                 else {
                     return true;
                 }
    
           }
    }

Similar Threads

  1. Combobox typeAhead/autocomplete for mode:'remote'
    By outrage in forum Ext 2.x: Help & Discussion
    Replies: 6
    Last Post: 24 Jun 2011, 6:57 AM
  2. Autocomplete and remote combobox issue
    By douggiefox in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 10 Mar 2010, 7:30 AM
  3. Remote populated ComboBox autoComplete: what's better solution
    By slimarafa in forum Ext GWT: Help & Discussion (1.x)
    Replies: 0
    Last Post: 16 Mar 2009, 7:06 AM
  4. Autocomplete on remote combobox?
    By mtrpcic in forum Ext 2.x: Help & Discussion
    Replies: 6
    Last Post: 16 Jan 2008, 12:46 PM

Tags for this Thread