combobox实现下拉列表多选, 效果如下
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAASMAAAEFCAIAAAAntxZRAAAUHUlEQVR4nO2da1PbSp6H9akow6cJLspfIbuf4AQqteGNq6bOzJt5sVu1WxlTzE5Yz7nsyUx2zmZ2nCGQhEmOQwgksbnYgG2ZWwDvC/nSLbVkdds0En6e+lcF22rAiZ78W23pJ6d9fk1R1E2Xc+u/AUVNQmEaRdkoTKMoG4VpFGWjMI2ibBSmUZSNwjSKslGYRlE2CtMoykZhGkXZKEyjKBuFaRRlozCtW+7ZtXt23aIo0/J2IUyLcqx1etU4uTpuXx25l4etyzpF6dRh6/LIvTxuXzVOrlqnV0rfJto0r4kdn1wdupf7za+Vo4vP9Yud2vl27Xz7gKLiVe18p3b+uX5RObrYb349dC+PT65agf420aa1zq4b7ata67JyePFh7+xt5fTVzsnax/bLrfbqlktRcerlVnvtY/vVzsnbyumHvbPK4UWtddloX7UwzSv37Pr45KrWuvxUv3hXOS1tur97Xv/Nj3v5YpWidOs3P+4VntdfbLrvKqef6he11uXxiTSNnFzTWqdXh+5l5fDiXeX0p9eN3z7d/1w/v7q67gD0qLlxa79xvbV/8e9/qT1903hXOa0cXhy6l63Tq0k3zT27bpxc7Te/ftg7e/HB/e3T/UscgwDxTfPqoHn9r88O/v7B/bB3tt/82hDa2uSadty+qhxdvK2cFp7XP9fPb/vfFJKIrmk1t7O5d1H4a/1t5bRydHHcnnjTWmfXR+7l5/rFq52Tb7/fvRb6meM4t/cvC8nCwLSDZufXP+y+2jn5XL84ci9b4zFtOedkHq2bDl+ac/SHP8mKQzYeZeaemJl22LrcqZ2vfWzni1XxLxfToI+BaTW3ky9W1z62d2rnh60Q05bmnCH4dmvRtOVcyJjcUoRpYZ6ovlt2+bp9fr3+cLo3qryQmV7YMOxp9dbldu385RamQSjGpr3cam/XzutRpoW3CMWrI/W08kIm6scFpOqa1j6/XpqbXti4Xn84nXlYNvrRPdMOzle3XEyDMIxNW91ytw/GYVqg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ojFVX4prD9EKExLCphmYprOOSIrOeHoTHFbp8BRWmQU8aDpid/VH0AubY9piQDTtE3TPu9ReffP6AzjsChioZN1/M1Mme+PaUkB0/RMuzk0o4jF+zsJz80sLkZ8VBD3m8P4wbSkmAZ3G0zDNLABpmEa2ADTMA1sgGmYBjbANEwDG2AapoENMA3TwAaYhmlgA0zDNLABpmEa2ADTMA1sgGl6ppFhDGZgmrZpZBiDAZhmYhoZxqALphmadlMZxmFBWf1LOv1hB8K128OvRxsegRyVhMflbSOAaSOZFifDuNPp7r/9XTQqdi7iNb9sypweX6RPeKg4Ech2wTRD02JnGHtZILncjK+3hIdZBV8Z1mjkoK2IgDsikG8NTDMxTSvDuNPpKEI+5H14YF7XDXn7sNzU3ljZrYFcqjQgIpBvB6Vp/w9mBVj/thaLoAAAAABJRU5ErkJggg==" alt="" />
一、先定义一个easyui-combobox
<td>
目标人群:
</td>
<td>
<input id="cmbAgeType" class="easyui-combobox" name="dept" />
</td>
二、在javascript中写入如下代码
$('#cmbAgeType').combobox({
url: 'AjaxHandler/RadioCommon.ashx?action=bindAgeType',//对应的ashx页面的数据源
method: 'get',
valueField: 'CID',//绑定字段ID
textField: 'CNAME',绑定字段Name
panelHeight: 'auto',//自适应
multiple: true,
formatter: function (row) {
var opts = $(this).combobox('options');
return '<input type="checkbox" class="combobox-checkbox" id="' + row[opts.valueField] + '">' + row[opts.textField]
}, onShowPanel: function () {
var opts = $(this).combobox('options');
var target = this;
var values = $(target).combobox('getValues');
$.map(values, function (value) {
var el = opts.finder.getEl(target, value);
el.find('input.combobox-checkbox')._propAttr('checked', true);
})
},
onLoadSuccess: function () {
var opts = $(this).combobox('options');
var target = this;
var values = $(target).combobox('getValues');
$.map(values, function (value) {
var el = opts.finder.getEl(target, value);
el.find('input.combobox-checkbox')._propAttr('checked', true);
})
},
onSelect: function (row) {
var opts = $(this).combobox('options');
var el = opts.finder.getEl(this, row[opts.valueField]);
el.find('input.combobox-checkbox')._propAttr('checked', true);
},
onUnselect: function (row) {
var opts = $(this).combobox('options');
var el = opts.finder.getEl(this, row[opts.valueField]);
el.find('input.combobox-checkbox')._propAttr('checked', false);
}
});
三、后台传到前台的Json格式
[{"CID":,"CNAME":"10岁以上","CSEX":,"CAGE":,"CEDUCATION":,"CINCOMING":,"CMARRY":,"CJOB":,"CDECIDER":,"CBACKUP1":,"CBACKUP2":,"CBACKUP3":,"CARG1":"","CARG2":"","CARG3":"","CVALID":,"CTX3":""},{"CID":,"CNAME":"男","CSEX":,"CAGE":,"CEDUCATION":,"CINCOMING":,"CMARRY":,"CJOB":,"CDECIDER":,"CBACKUP1":,"CBACKUP2":,"CBACKUP3":,"CARG1":"","CARG2":"","CARG3":"","CVALID":,"CTX3":""},{"CID":,"CNAME":"女","CSEX":,"CAGE":,"CEDUCATION":,"CINCOMING":,"CMARRY":,"CJOB":,"CDECIDER":,"CBACKUP1":,"CBACKUP2":,"CBACKUP3":,"CARG1":"","CARG2":"","CARG3":"","CVALID":,"CTX3":""},{"CID":,"CNAME":"10-19岁","CSEX":,"CAGE":,"CEDUCATION":,"CINCOMING":,"CMARRY":,"CJOB":,"CDECIDER":,"CBACKUP1":,"CBACKUP2":,"CBACKUP3":,"CARG1":"","CARG2":"","CARG3":"","CVALID":,"CTX3":""},{"CID":,"CNAME":"20-29岁","CSEX":,"CAGE":,"CEDUCATION":,"CINCOMING":,"CMARRY":,"CJOB":,"CDECIDER":,"CBACKUP1":,"CBACKUP2":,"CBACKUP3":,"CARG1":"","CARG2":"","CARG3":"","CVALID":,"CTX3":""},{"CID":,"CNAME":"30-39岁","CSEX":,"CAGE":,"CEDUCATION":,"CINCOMING":,"CMARRY":,"CJOB":,"CDECIDER":,"CBACKUP1":,"CBACKUP2":,"CBACKUP3":,"CARG1":"","CARG2":"","CARG3":"","CVALID":,"CTX3":""},{"CID":,"CNAME":"40-49岁","CSEX":,"CAGE":,"CEDUCATION":,"CINCOMING":,"CMARRY":,"CJOB":,"CDECIDER":,"CBACKUP1":,"CBACKUP2":,"CBACKUP3":,"CARG1":"","CARG2":"","CARG3":"","CVALID":,"CTX3":""},{"CID":,"CNAME":"50岁以上","CSEX":,"CAGE":,"CEDUCATION":,"CINCOMING":,"CMARRY":,"CJOB":,"CDECIDER":,"CBACKUP1":,"CBACKUP2":,"CBACKUP3":,"CARG1":"","CARG2":"","CARG3":"","CVALID":,"CTX3":""}]