combotree :
设置为多选框: $('#menu-combotree').combotree({multiple:true}).combotree('loadData', menuListJson).combotree('setValues', moduleMenuIds);
<select id="menu-combotree" name="m_ids[]" style=" 200px;"></select>
var menuListJson = [{"id":"1","text":"u57fau672cu7ba1u7406(---)","parent":"0","children":[{"id":"2","text":"u7ba1u7406u5458u7ba1u7406(---)","parent":"1"},{"id":"3","text":"u4feeu6539u5bc6u7801(---)","parent":"1"},{"id":"4","text":"u8bbeu7f6eu6b22u8fceu8bcd(---)","parent":"1"},{"id":"5","text":"u6743u9650u5206u914d(---)","parent":"1"},{"id":"6","text":"u4f01u4e1au4fe1u606f(---)","parent":"1"},{"id":"52","text":"u63a8u9001u8bbeu7f6e(---)","parent":"1"},{"id":"59","text":"u5ba2u670du914du7f6e(---)","parent":"1"}]},{"id":"7","text":"u4e00u7ebfu5ba2u670du7ba1u7406(---)","parent":"0","children":[{"id":"8","text":"u5ba2u670du7ec4u7ba1u7406(---)","parent":"7"},{"id":"79","text":"u5ba2u6237u7ec4u6307u5b9au5ba2u670du7ec4(---)","parent":"7"},{"id":"9","text":"u5ba2u670du7ba1u7406(---)","parent":"7"},{"id":"10","text":"u5b9eu65f6u76d1u63a7(---)","parent":"7"}]},{"id":"11","text":"u4e8cu7ebfu5ba2u670du7ba1u7406(---)","parent":"0","children":[{"id":"12","text":"u5ba2u670du7ec4u7ba1u7406(---)","parent":"11"},{"id":"13","text":"u5ba2u670du7ba1u7406(---)","parent":"11"},{"id":"14","text":"u5b9eu65f6u76d1u63a7(---)","parent":"11"}]},{"id":"15","text":"u5ba2u6237u7ba1u7406(---)","parent":"0","children":[{"id":"16","text":"u5ba2u6237u7ec4u7ba1u7406(---)","parent":"15"},{"id":"17","text":"u5ba2u6237u7ba1u7406(---)","parent":"15"}]},{"id":"18","text":"u6d88u606fu7ba1u7406(---)","parent":"0","children":[{"id":"19","text":"u4f1au8bddu5206u7ec4(---)","parent":"18"},{"id":"20","text":"u4f1au8bddu5386u53f2(---)","parent":"18"}]},{"id":"21","text":"u63d2u4ef6u7ba1u7406(---)","parent":"0","children":[{"id":"22","text":"u63d2u4ef6u5217u8868(---)","parent":"21"},{"id":"47","text":"u5173u952eu8bcdu56deu590d(---)","parent":"21"},{"id":"48","text":"u81eau5b9au4e49u56deu590d(---)","parent":"21"},{"id":"49","text":"u5730u7406u4f4du7f6eu56deu590d(---)","parent":"21"}]},{"id":"23","text":"u7fa4u53d1u7ba1u7406(---)","parent":"0","children":[{"id":"24","text":"u7fa4u53d1u6d88u606f(---)","parent":"23"},{"id":"25","text":"u7fa4u53d1u5386u53f2(---)","parent":"23"},{"id":"77","text":"u6d88u8d39u7ba1u7406(---)","parent":"23"},{"id":"60","text":"u6a21u677fu7fa4u53d1(---)","parent":"23"}]},{"id":"26","text":"u7edfu8ba1u62a5u8868(---)","parent":"0","children":[{"id":"27","text":"u5ba2u6237u7edfu8ba1(---)","parent":"26"},{"id":"28","text":"u4f1au8bddu7edfu8ba1(---)","parent":"26"},{"id":"29","text":"u5ba2u670du670du52a1u7edfu8ba1(---)","parent":"26"},{"id":"53","text":"u6d88u606fu660eu7ec6(---)","parent":"26"}]},{"id":"30","text":"u95e8u5e97u7ba1u7406(---)","parent":"0","children":[{"id":"31","text":"u95e8u5e97u7ba1u7406(---)","parent":"30"},{"id":"32","text":"u95e8u5e97u5206u914d(---)","parent":"30"},{"id":"41","text":"u5ba2u6237u7ba1u7406(---)","parent":"30"},{"id":"44","text":"u7fa4u53d1u6d88u606f(---)","parent":"30"},{"id":"45","text":"u7fa4u53d1u5386u53f2(---)","parent":"30"},{"id":"46","text":"u6279u91cfu5bfcu5165(---)","parent":"30"}]},{"id":"36","text":"u4f1au5458u7ed1u5b9a(---)","parent":"0","children":[{"id":"37","text":"u7ed1u5b9au8bbeu7f6e(---)","parent":"36"},{"id":"61","text":"u4f1au5458u7ed1u5b9au5217u8868(---)","parent":"36"}]},{"id":"38","text":"u7d20u6750u7ba1u7406(---)","parent":"0","children":[{"id":"39","text":"u56feu6587u7d20u6750(---)","parent":"38"},{"id":"55","text":"u56feu7247u7d20u6750(---)","parent":"38"},{"id":"74","text":"u8bedu97f3u7d20u6750(---)","parent":"38"},{"id":"75","text":"u89c6u9891u7d20u6750(---)","parent":"38"},{"id":"76","text":"u97f3u4e50u7d20u6750(---)","parent":"38"}]},{"id":"42","text":"u81eau5b9au4e49u83dcu5355(---)","parent":"0","children":[{"id":"43","text":"u83dcu5355u7ba1u7406(---)","parent":"42"}]},{"id":"50","text":"u4e8cu7ef4u7801u5e94u7528(---)","parent":"0","children":[{"id":"51","text":"u5e94u7528u5217u8868(---)","parent":"50"},{"id":"63","text":"u4f1au5458u7ed1u5b9a(---)","parent":"50"},{"id":"64","text":"u6d3bu52a8u63a8u5e7f(---)","parent":"50"},{"id":"65","text":"u5546u54c1u4e8cu7ef4u7801(---)","parent":"50"},{"id":"66","text":"u95e8u5e97u63a8u5e7f(---)","parent":"50"},{"id":"67","text":"u4fddu4feeu5361(---)","parent":"50"},{"id":"70","text":"u81eau5b9au4e49u4e8cu7ef4u7801(---)","parent":"50"}]},{"id":"58","text":"u76d1u6d4bu7ba1u7406(---)","parent":"0","children":[{"id":"56","text":"u6765u6e90u5a92u4f53u7ba1u7406(---)","parent":"58"},{"id":"57","text":"u7f51u9875u76d1u6d4bu7ba1u7406(---)","parent":"58"},{"id":"68","text":"u7f51u9875u76d1u6d4bu62a5u8868(---)","parent":"58"},{"id":"62","text":"u6d3bu52a8u76d1u6d4bu7ba1u7406(---)","parent":"58"},{"id":"69","text":"u6d3bu52a8u76d1u6d4bu62a5u8868(---)","parent":"58"}]},{"id":"71","text":"IVRu7ba1u7406(---)","parent":"0","children":[{"id":"72","text":"IVRu83dcu5355u7ba1u7406(---)","parent":"71"},{"id":"73","text":"u4e1au52a1u6d41u7a0bu7ba1u7406(---)","parent":"71"},{"id":"78","text":"u4e1au52a1u6d41u7a0bu660eu7ec6(---)","parent":"71"}]},{"id":"33","text":"u67e5u770bu8bb0u5f55(---)","parent":"0"},{"id":"34","text":"u8f6cu4e8cu7ebfu5ba2u670d(---)","parent":"0"},{"id":"35","text":"u5ba2u6237u5206u7ec4(---)","parent":"0"}];
var moduleMenuIds = ["2","3","4","5","6","16","17","56","57","62","68","69"];
$('#menu-combotree').combotree({multiple:true}).combotree('loadData', menuListJson).combotree('setValues', moduleMenuIds);
http://www.oschina.net/code/snippet_12_4021
<script type="text/javascript" src="./Public/js/jquery.js"></script>
<link type="text/css" rel="stylesheet" href="./Public/js/EasyUI/css/icon.css" />
<link type="text/css" rel="stylesheet" href="./Public/js/EasyUI/css/easyui.css" />
<script type="text/javascript" src="./Public/js/EasyUI/jquery.easyui.min.js"></script>
<select id="module-combotree" name="mod_ids[]" style=" 200px;"></select>
$(document).ready(function(){
var AllList = <?php echo $pluginListJson;?>;
var defaultIds = <?php echo $entPluginIds;?>;
$('#module-combotree').combotree({multiple:true}).combotree('loadData', AllList).combotree('setValues',defaultIds);
var url = "<?php echo url('EntPluginManager', 'update');?>";
var href = "<?php echo url('EntPluginManager', 'index');?>";
$('#submit').click(function (){
var id = $.trim($('#id').val());
var ids = $('#module-combotree').combotree("getValues");
var params = {
id:id,
ids:ids,
};
submit_operate(url,params,href);
});
});
if ($ent) {
$pluginAllList = $this->model->getPluginListCombotree();
$entPluginList = $this->model->getEntPluginIdsByEntId($id);
}
$this->assign('pluginListJson', json_encode($pluginAllList));
$this->assign('entPluginIds', json_encode($entPluginList));
/**
* 获取企业插件列表Combotree数据
* @return array
*/
public function getPluginListCombotree()
{
$list = array();
$PluginList = $this->getList();
if ($PluginList) {
foreach ($PluginList as $k => $v) {
$list[] = array(
'id' => $v['plugin_id'],
'text' => $v['plugin_name']
);
}
}
return $list;
}
/**
* 获取企业插件ID集合
* @param int $ent_id
* @return array
*/
public function getEntPluginIdsByEntId($ent_id)
{
$sql = "SELECT plugin_id FROM `wx_ent_plugins` WHERE ent_id = %d";
try {
return $this->dbBase->getCol(sprintf($sql, $ent_id));
} catch ( Exception $e ) {
Logger::error(__FILE__ . ' ' . __CLASS__ . ' ' . __METHOD__ . ' ' . __LINE__ . ' ',
$e->getMessage() . "
" . $e->getTraceAsString());
return false;
}
}