EasyUI Combo Checkbox
页面:
<select id="selTONodes">
</select>
<div id="divTONodes">
</div>
JS:
第一步:
$(function(){
$('#selTONodes').combo({
required: true,
editable: false,
multiple: true,
panelHeight: 'auto'
});
$('#divTONodes').appendTo($('#selTONodes').combo('panel'));
});
第二步:
for (var i = 0; i < data.length; i++) {
$("#divTONodes").append("<input type='checkbox' name='tonodes' value='" + data[i].Nid + "' onclick='GetTONodes()'/><span>" + data[i].Nname + "</span><br />");
}
第三步:
function GetTONodes() {
var v = [];
var s = '';
$("input[name='tonodes']:checkbox").each(function () {
if ($(this).attr("checked")) {
v.push($(this).val());
if (s != '') {
s += ',';
}
s += $(this).next('span').text();
}
});
$('#selTONodes').combo('setValues', v).combo('setText', s);
}