On the implementation of multi-selection and additional checkbox for ComboBox in Easyui

Source: Internet
Author: User

The ComboBox has only a RadioButton effect in the Easyui's base assembly, and only supports single-radio.

But on the basis of this control, we can rewrite the ComboBox to achieve the CheckBox multi-selection effect.

There are a few ways to rewrite the following:

Format:function (Row) {var opts = $ (this). ComboBox ("Options"); Return "<input type= ' checkbox ' class= ' Combobox-checkbox ' >" + Row[opts.textfield];}
Onshowpanel:function () {
var opts = $ (this). ComboBox ("Options");    target = this;    var values = $ (target). ComboBox ("GetValues"); $.map (values, function (value) {var children = $ (target). ComboBox ("Panel"). Children (); $.each (children, function (Inde X, obj) {if (value = = Obj.getattribute ("value") && obj.children && obj.children.length > 0) {o Bj.children[0].checked = true;
}}); });}
Onloadsuccess:function () {var opts = $ (this). ComboBox ("Options");    var target = this;    var values = $ (target). ComboBox ("GetValues"); $.map (values, function (value) {var children = $ (target). ComboBox ("Panel"). Children (); $.each (children, function (Inde X, obj) {if (value = = Obj.getattribute ("value") && obj.children && obj.children.length > 0) {o Bj.children[0].checked = true;
}}); });}

onselect : function (row) {    var opts = $ (this). ComboBox ("Options");    var objcom = null;     var children = $ (This). ComboBox ("Panel"). Children ();     $.each (Children,  function (index, obj) {        if (row[opts.valueField] = = obj.getattribute ("value")) {    objcom = obj;}     });     if (objcom != null &&  objcom.children && objcom.children.length > 0) {         objcom.children[0].checked = true;    }} 


Onunselect:function (Row) {
var opts = $ (this). ComboBox ("Options");    var objcom = null;    var children = $ (this). ComboBox ("Panel"). Children (); $.each (children, function (index, obj) {if (Row[opts.valuefield] = = Obj.getattribute ("value")) {objcom = obj;}
}); if (objcom! = null && objcom.children && objCom.children.length > 0) {objcom.children[0].checked    = false; }}

after overriding the above methods, you can implement multiple selections with a checkbox for the ComboBox

On the implementation of multi-selection and additional checkbox for ComboBox in Easyui

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.