Easyui ComboBox to open the search automatic completion of the instance code _javascript tips

Source: Internet
Author: User

Combo.json

[{
 "id":-1,
 "text": ",
 " spell ":" "

},{
 " id ": 1,
 " text ":" Type 1 ",
 " spell ":" Lx1 "
},{
 "id": 2,
 "text": "Type 2",
 "spell": "LX2"
},{
 "id": 3,
 "text": "Type 3",
 "spell": "Lx3 "
},{
 " ID: 4,
 "text": "Type 4",
 "spell": "Lx4"
},{
 "id": 5,
 "text": "Type 5",
 " Spell ":" Lx5 "
}]

The following is a code example

<form>
  <input type= "text" id= "Combox1" >
</form>
/** * Easyui ComboBox Opens the search function, automatically loads the selected item handler function */function Oncomboboxhidepanel () {var el = $ (this);
    El.combobox (' textbox '). focus ();
    Check whether the input content is in the data var opts = El.combobox ("Options");
    var data = El.combobox ("GetData");
    var value = El.combobox ("GetValue");
    If there are highlighted items, the var panel = el.combobox ("panel") is not further processed;
    var items = Panel.find (". combobox-item-selected");
      if (Items.length > 0) {var values = El.combobox ("GetValues");
      El.combobox ("Setvalues", values);
    Return
    var allowinput = opts.allowinput;

      if (allowinput) {var idx = data.length;
      DATA[IDX] = [];
      Data[idx][opts.textfield] = value;
      Data[idx][opts.valuefield] = value;
    El.combobox ("LoadData", data);
    else {//Do not allow entry of any item, then empty El.combobox ("clear"); } $ ("#combox1"). ComboBox ({required:true, editable:true, missingmessage: ' Please select loading item ', Valuefield: "I D ", TextField:" Text ", Method:' Get ', url: ' Combo.json ', mode: ' Local ', Onhidepanel:oncomboboxhidepanel, Filter:function (q, Row) {
      Defines how local data is filtered when ' mode ' is set to ' locals ', and the function has 2 parameters://q: The text entered by the user.
      Row: List row data.
      Allows rows to be displayed when True is returned.
      Return row[$ (This). ComboBox (' Options '). Textfield].indexof (Q) >-1;
    return row["spell"].indexof (q) >= 0; }
  });

Above this article Easyui ComboBox open Search automatic completion of the example code is a small series to share all the content, hope to give you a reference, but also hope that we support the cloud-dwelling community.

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.