EasyUI Tree节点拖动到指定容器
2016-01-03 16:42
471 查看
效果图:将tree节点拖动到指定的DIV中,结果显示节点的id和text
代码:
说明:
使用“允许拖动”按钮进行设置拖动时需要在树加载后才生效
使用on方式设置则不需要等待树加载完成即可,但测试中发现单击展开/收缩节点功能失效,加了个click方法,还是要双击才生效,需要改进。
代码:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Drag Drop Tree Nodes - jQuery EasyUI Demo</title> <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css"> <link rel="stylesheet" type="text/css" href="../../themes/icon.css"> <link rel="stylesheet" type="text/css" href="../demo.css"> <script type="text/javascript" src="../../jquery.min.js"></script> <script type="text/javascript" src="../../jquery.easyui.min.js"></script> </head> <body> <h2>Drag Drop Tree Nodes<input type="button" onclick="enableDragg();" value="允许拖动" /><input type="button" onclick=" disableDragg();" value="禁止拖动" /></h2> <p>Press mouse down and drag a node to another position.</p> <div style="margin: 20px 0;"></div> <div class="easyui-panel" style="padding: 5px"> <ul class="easyui-tree" data-options="url:'tree_data1.json',method:'get',animate:true,dnd:false" id="tree"></ul> </div> <div id="drop" style="height: 200px; border: 1px green solid; margin-top: 5px;"></div> </body> </html> <script type="text/javascript"> $(function () { $('#drop').droppable({ onDrop: function (e, source) { var node = $('#tree').tree('getNode', source); $(this).append("<div>node.id:" + node.id + ", node.text:" + node.text + "</div>"); } }); $('#tree').on({ mouseover: function (e) { var target = e.target; if (target.tagName == 'SPAN') target = target.parentNode; $(target).draggable({ revert: true, proxy: 'clone', disabled: false }) }, click: function (e) { var target = e.target; if (target.tagName == 'SPAN') target = target.parentNode; if (target.tagName == 'LI') target = $(target).find('div:first')[0]; $(this).tree('toggle',target); } }); }); function enableDragg() { $('.tree-node').draggable({ revert: true, proxy: 'clone', disabled: false }); }; function disableDragg() { $('.tree-node').draggable({ disabled: true }); } </script>
说明:
使用“允许拖动”按钮进行设置拖动时需要在树加载后才生效
使用on方式设置则不需要等待树加载完成即可,但测试中发现单击展开/收缩节点功能失效,加了个click方法,还是要双击才生效,需要改进。
相关文章推荐
- ios uialertview
- ios uitableviewcell 的具体功能实现
- iOS之UITableView组头组尾视图/标题悬停
- [easyui]单例模式封装组件,提高性能,按需使用
- Android高性能加载大量图片系列课程2-在非UI线程中处理图片
- EASYUI DATAGRID 多列复选框CheckBox
- 30分钟 带你浅入requirejs源码
- requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
- iOS开发- reloadData无效 (子线程更新UI错误)
- .NET中类型转换的一些等价用法
- Unexpected error: Invalid byte sequence in conversion input的问题
- 手势
- android中从values/strings资源文件中获取拼接字符串的方法
- Ueditor文本编辑器图片上传配置
- 在easyui框架中使用JS和window.open方法提交数据至Servlet并导出POI数据表格
- KAGGLE ENSEMBLING GUIDE
- UICollectionView自定义流水布局
- leetcode, Range Sum Query - Mutable
- burpsuite的基础应用-暴力破解
- soap request by afnetworking2.X/3.X