EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: lyz19890927 on August 14, 2012, 06:18:18 PM



Title: Hope there is an option for combobox to show checkbox
Post by: lyz19890927 on August 14, 2012, 06:18:18 PM
I think right now this hasn't been offered yet. Is there other way to achieve?

Just like combotree,if we can see the checkboxes ,it will be much clearer when users choose.

In combotree,the Property 'onlyLeafCheck' works when I set 'multiple : true, checkbox : true', hope it works too when I set ''multiple : false, checkbox : true', i.e. single select.

Another question , in datagrid we have the handler onSortColumn now . But I couldn't stop the sort action by it.Hope give some tip. Many thanks!


Title: Re: Hope there is an option for combobox to show checkbox
Post by: Andy1980 on November 15, 2013, 08:05:35 AM
Hi,

you can easy achieve this with the normal combo like that:

Code:
	<select id="cc2" style="width:150px"></select>
    <div id="sp">
        <div style="color:#99BBE8;background:#fafafa;padding:5px;">Select a language</div>
        <input type="checkbox" name="lang" value="01"><span>Java</span><br/>
        <input type="checkbox" name="lang" value="02"><span>C#</span><br/>
        <input type="checkbox" name="lang" value="03"><span>Ruby</span><br/>
        <input type="checkbox" name="lang" value="04"><span>Basic</span><br/>
        <input type="checkbox" name="lang" value="05"><span>Fortran</span>
    </div>

Code:
            $('#cc2').combo({
                required:true,
                editable:false,
multiple:true
            });
           $('#sp').appendTo($('#cc2').combo('panel'));
           $('#sp input').click(function(){
var my_text = '';
var my_val = '';
   
$('#sp input').each(function(){
if ($(this).is(":checked")) {
var v = $(this).val();
var s = $(this).next('span').text();

my_text == '' ? my_text = s : my_text += ','+s;
my_val  == '' ? my_val = v : my_val += ','+v;
}
});

$('#cc2').combo('setValue', my_val).combo('setText', my_text);
            });