<td width="15%" class="main_form_tabletitle">所属地区:</td> <td width="35%"> <input id="orgCode" name="orgCode" class="easyui-combobox" required=true missingMessage="必填"> </td>
$(function(){ //初始化多选复选框(所属地区) initCombobox('orgCode'); }); function initCombobox(id){ var selectedText = []; //加载下拉框复选框 $('#'+id).combobox({ url:'/promotionReward/queryEngineerFixAssignArea.do', //后台获取下拉框数据的url method:'post', panelHeight:200,//设置为固定高度,combobox出现竖直滚动条 valueField:'deptCode', textField:'deptName', multiple:true, editable:false, formatter: function (row) { //formatter方法就是实现了在每个下拉选项前面增加checkbox框的方法 var opts = $(this).combobox('options'); if($('#deptCode').val().indexOf(row[opts.valueField]) != -1){ selectedText.push(row[opts.valueField]); return '<option selected="selected">' + row[opts.textField] + '</option>'; }else{ return '<option>' + row[opts.textField] + '</option>'; } }, onLoadSuccess: function () { //下拉框数据加载成功调用 $(this).combobox('setValues', selectedText);//填充数据 }, onSelect: function (row) { //选中一个选项时调用 $(this).combobox('setValues', $(this).combobox('getValues')); }, onUnselect: function (row) {//不选中一个选项时调用 } }); }