easyui combotree combobox 使用例子
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <link href="Resurces/themes/easyui.css" rel="stylesheet" /> <link href="Resurces/themes/icon.css" rel="stylesheet" /> <script src="Resurces/Javascript/jquery.min.js"></script> <script src="Resurces/Javascript/jquery.easyui.min.js"></script> <script> $(function () { $('#cc').combotree({ method: 'get', //必须指明 url: 'Data/tree_data1.json',//必须指明 editable: true, //编辑,支持模糊查询 multiple: true, //为true,出来多选框,勾选多个 required: true, missingMessage: '不能为空,请选择', prompt: '请选择下拉...', onHidePanel: function () { var _options = $(this).combobox('options'); var _data = $(this).combobox('getData');/* 下拉框所有选项 */ var _value = $(this).combobox('getValue');/* 用户输入的值 */ var _b = false;/* 标识是否在下拉列表中找到了用户输入的字符 */ for (var i = 0; i < _data.length; i++) { if (_data[i][_options.valueField] == _value) { _b = true; break; } } if (!_b) { $(this).combobox('setValue', ''); } } }); $('#dd').combobox({ method: 'get', //必须指明 url: 'Data/combox1.json',//必须指明 valueField: 'id', textField: 'text', editable: true, //编辑,支持模糊查询 //multiple: true, //为true,出来多选框,勾选多个 required: true, onChange: function (newValue, oldValue) { reload();//实现联动 } }); }); function reload() { $('#dd').combobox({ method: 'reload', //必须指明 url: 'Data/combox1.json?param='+'这里是传的新值'+'&a='+Math.random()//必须指明 }); } function GetData() { var t = $('#cc').combotree('getData'); alert(t.length); } function SetDefault() { var t = $('#cc').combotree('getData'); $('#cc').combotree('select',t[0].id); } function getValues() { var t = $('#cc').combotree('getValues'); alert(t); } function getValue() { var t = $('#cc').combotree('getValue'); alert(t); } function setValues() { $('#cc').combotree('setValues', ['111', '112']); } function setValue() { $('#cc').combotree('setValue', '11'); } function disable() { $('#cc').combotree('disable'); } function enable() { $('#cc').combotree('enable'); } </script> </head> <body> <form id="form1" runat="server"> <div> <input id="cc" /> <input id="dd" /> <input type="button" value="getValue" onclick="getValue()" /> <input type="button" value="getValues" onclick="getValues()" /> <input type="button" value="setValue" onclick="setValue()" /> <input type="button" value="setValues" onclick="setValues()" /> <input type="button" value="disable" onclick="disable()" /> <input type="button" value="enable" onclick="enable()" /> </div> </form> </body> </html>
天生我材必有用,千金散尽还复来
分类:
EasyUI
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)