actions.html 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Tree Actions - jQuery EasyUI Demo</title>
  6. <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
  7. <link rel="stylesheet" type="text/css" href="../../themes/icon.css">
  8. <link rel="stylesheet" type="text/css" href="../demo.css">
  9. <script type="text/javascript" src="../../jquery.min.js"></script>
  10. <script type="text/javascript" src="../../jquery.easyui.min.js"></script>
  11. </head>
  12. <body>
  13. <h2>Tree Actions</h2>
  14. <p>Click the buttons below to perform actions.</p>
  15. <div style="margin:20px 0;">
  16. <a href="#" class="easyui-linkbutton" onclick="collapseAll()">CollapseAll</a>
  17. <a href="#" class="easyui-linkbutton" onclick="expandAll()">ExpandAll</a>
  18. <a href="#" class="easyui-linkbutton" onclick="expandTo()">ExpandTo</a>
  19. <a href="#" class="easyui-linkbutton" onclick="getSelected()">GetSelected</a>
  20. </div>
  21. <div class="easyui-panel" style="padding:5px">
  22. <ul id="tt" class="easyui-tree" data-options="url:'tree_data1.json',method:'get',animate:true"></ul>
  23. </div>
  24. <script type="text/javascript">
  25. function collapseAll(){
  26. $('#tt').tree('collapseAll');
  27. }
  28. function expandAll(){
  29. $('#tt').tree('expandAll');
  30. }
  31. function expandTo(){
  32. var node = $('#tt').tree('find',113);
  33. $('#tt').tree('expandTo', node.target).tree('select', node.target);
  34. }
  35. function getSelected(){
  36. var node = $('#tt').tree('getSelected');
  37. if (node){
  38. var s = node.text;
  39. if (node.attributes){
  40. s += ","+node.attributes.p1+","+node.attributes.p2;
  41. }
  42. alert(s);
  43. }
  44. }
  45. </script>
  46. </body>
  47. </html>