easyui之combotree下拉框多选框

时间:2024-04-02 20:10:36

1、导入easyui相关jar包
easyui之combotree下拉框多选框注意:引入easyui的js时,如果同时需要引入jquery.js。在使用的时候,需要先加载jquery.js,否则的话,会导致easyui的js失效。
2、前端代码的实现
easyui之combotree下拉框多选框注意:在html或jsp页面,写一个select下拉列表,class='easyui-combotree’即可。
3、获取数据并渲染到标签上
easyui之combotree下拉框多选框注意:
通过$("#ddlLine").combobox(“getValues”);获得选中的所有value值。

通过$("#ddlLine").combobox(“getValue”);获得选中的第一个value值。

通过$("#ddlLine").combobox(“getText”);获得选中的文本值。
具体案例:
easyui之combotree下拉框多选框
4、数据的回显
具体案例:
easyui之combotree下拉框多选框
注意:
1、先获取未被选中的多选框节点
//获取未选中的节点 value值为:node.id text值:node.text
var nodes = $("#ddlLine").combotree(‘tree’).tree(‘getChecked’, ‘unchecked’);

2、将后端获取的内容,渲染到多选框中
$("#ddlLine").combotree(‘tree’).tree(‘check’,nodes[i].target);//选中指定的节点

总结:多参考官方文档开发,有利于提升自己的开发能力。如有不清楚的,欢迎私聊我。