ExtJS ComboBox Implementation of the search box effect

Source: Internet
Author: User

Purpose: Use the ComboBox to achieve a similar search box effect, that is, after the user enters the content, appears the related following list, provides the choice.

Implementation: EXTJS3 in the ComboBox itself with this function.

Properties that need to be set:

1. Hidetrigger:true,//Remove the small logo on the right

2. Mode: ' Remote ',//data needs to be downloaded remotely

3. Minchars:2,//Set the query to be triggered when the user input character number

4. Queryparam: ' Userinput ',//Set the name of the user pass parameter, default is ' query '

Definition of Store:

  var ds = new Ext.data.Store ({      proxy:new Ext.data.HttpProxy ({               url:web_context+ ' xxx.action ',         method: ' Post '        }),      reader:new Ext.data.JsonReader ({}, [{           name: ' VALUE '          }, {           name: ' TEXT '          }])  });

When the user enters 2 characters, the store is loaded, the background is called, and the user input can be obtained in the background. ("Userinput"), in the background processing when the user input parameters, to get the desired store content.

You can add the Beforquery function to see

  listeners:{Beforequery:function (QE) {       var para = qe.query;   }              }

Chrome Break Point debugging

Found in the source code:

Doquery:function (q, forceall) {q = ext.isempty (q)?        ": Q;        var QE = {query:q, Forceall:forceall, Combo:this, cancel:false};        if (this.fireevent (' beforequery ', QE) ===false | | qe.cancel) {return false;        } q = qe.query;        Forceall = Qe.forceall; if (Forceall = = = True | | (Q.length >= This.minchars))                {if (this.lastquery!== q) {this.lastquery = q;                    if (This.mode = = ' local ') {this.selectedindex =-1;                    if (Forceall) {this.store.clearFilter ();                    }else{This.store.filter (This.displayfield, q);                } this.onload ();  }else{This.store.baseparams[this.queryparam] = q;    Q Enter content for user this.store.load ({params:this.getParams (q)//load store here                });                This.expand ();                }}else{This.selectedindex =-1;            This.onload (); }        }    },

  

ExtJS ComboBox Implementation of the search box effect

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.