jQuery easyUI combotree和combobox使用实例

后台代码:

 

@ActionAnnotation(name = "查询数据字典列表",group = "查询", check = LOGIN)
public ModelAndView queryCombotree(HttpServletRequest request, HttpServletResponse response) throws Exception {
String sd_code = request.getParameter("sd_code");

Dict dict = new Dict();
dict.setMode("sd_code");
dict.setSd_code(sd_code);
dict.setSd_parent_id(Dict.ROOT_CODE);
Dict query = dictService.query(dict);

Dict dict2 = new Dict();
dict2.setMode("sd_path2");
dict2.setSd_path(query.getSd_id());

String tree = dictService.treeSingle(dict2);
return responseText(response, tree);
}


前台代码:

$("#wf_type").combotree({
url:"${path}/sys/dict_
queryCombotree.do?sd_code=flowtype",

editable : false ,

valueField : 'id',

textField : 'text',

onSelect: function(data) {

//返回树对象

var tree = $('#wf_type').combotree('tree').tree;

//选中的节点是否为叶子节点,如果不是叶子节点,清除选中

var isLeaf = tree('isLeaf', data.target);

if (!isLeaf) {

$.messager.alert("系统提示", "请选择具体流程!", "info");

$('#wf_type').combotree('clear');

return;

}

$("#wf_id").combobox({

url:"${path}/work/task_flowList.do?wf_type=" + data.id,

editable : false ,

width:"308",

valueField : 'wf_id',

textField : 'wf_name',

onSelect:function(data) {

$("#tbody").empty();

var date = new Date();

var a = date.getFullYear() + "" + (date.getMonth() + 1) + date.getDate() + date.getHours() + date.getMinutes() + date.getSeconds();

$("#wt_name").val(data.wf_name + a + "${loginUser.su_name}");

$.ajaxPost("${path}/work/flowStep_showStep.do", {"wf_id":data.wf_id}, function(result) {

var datas = eval(result);

$.each(datas, function(i, o) {

if (i == 0) {

$("#wt_auditer_target").val(o.wfs_auditer);

$("#wfs_type").val(o.wfs_type);

$("#wfs_id").val(o.wfs_id);

}

var html = "<tr><td class='th'>" + o.wfs_name + "</td>";

html += "<td class='td'>" + o.wfs_auditer_name + "</td></tr>";

$("#tbody").append(html);

});

});

}

});

}

});


<tr>
<td class="th">流程类型</td>
<td class="td"><input type="text" id="wf_type" name="wf_type" class="input"
validType="maxLength[32]" style="width:308px;"/></td>
</tr>
<tr>
<td class="th">流程</td>
<td class="td"><input type="text" id="wf_id" name="wf_id" class="input"
validType="maxLength[32]" style="width:300px;"/></td>
</tr>