treeselect.htm 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title></title>
  5. <script src="../../lib/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
  6. <link href="../../lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
  7. <script src="../../lib/ligerUI/js/core/base.js" type="text/javascript"></script>
  8. <script src="../../lib/ligerUI/js/plugins/ligerTree.js" type="text/javascript"></script>
  9. <script type="text/javascript">
  10. var tree = null;
  11. $(function ()
  12. {
  13. tree = $("#tree1").ligerTree({
  14. data: [
  15. { text: '节点1', children: [
  16. { text: '节点1.1' },
  17. { text: '节点1.2' },
  18. { text: '节点1.3', children: [
  19. { text: '节点1.3.1' },
  20. { text: '节点1.3.2' }
  21. ]
  22. },
  23. { text: '节点1.4' }
  24. ]
  25. },
  26. { text: '节点2' },
  27. { text: '节点3' },
  28. { text: '节点4' }
  29. ]
  30. });
  31. });
  32. function f_selectNode()
  33. {
  34. var parm = function (data)
  35. {
  36. return data.text.indexOf('节点1.3') == 0;
  37. };
  38. tree.selectNode(parm);
  39. }
  40. function f_cancelSelect()
  41. {
  42. var parm = function (data)
  43. {
  44. return false;
  45. };
  46. tree.selectNode(parm);
  47. }
  48. </script>
  49. </head>
  50. <body style="padding:10px">
  51. <div>
  52. <a class="l-button" style="width:120px; margin-left:10px; float:left;" onclick="f_selectNode()">选择行</a>
  53. <a class="l-button" style="width:120px; margin-left:10px;float:left;" onclick="f_cancelSelect()">反选择行</a>
  54. </div>
  55. <div style="width:200px; height:300px; margin:10px; float:left; clear:both; border:1px solid #ccc; overflow:auto; ">
  56. <ul id="tree1"></ul>
  57. </div>
  58. <div style="display:none">
  59. </div>
  60. </body>
  61. </html>