95d3caf5a93eda588f0c359cacc973ea1bcbd835.svn-base 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  2. <%
  3. String path = request.getContextPath();
  4. %>
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7. <head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  9. <title></title>
  10. <!--框架必需start-->
  11. <script type="text/javascript" src="<%=path%>/libs/js/jquery.js"></script>
  12. <script type="text/javascript" src="<%=path%>/libs/js/language/cn.js"></script>
  13. <script type="text/javascript" src="<%=path%>/libs/js/framework.js"></script>
  14. <link href="<%=path%>/libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
  15. <link rel="stylesheet" type="text/css" id="skin" prePath="<%=path%>/"/>
  16. <link rel="stylesheet" type="text/css" id="customSkin"/>
  17. <!--框架必需end-->
  18. <!-- 树组件start -->
  19. <script type="text/javascript" src="<%=path%>/libs/js/tree/ztree/ztree.js"></script>
  20. <link href="<%=path%>/libs/js/tree/ztree/ztree.css" rel="stylesheet" type="text/css"/>
  21. <!-- 树组件end -->
  22. <!--箭头分页start-->
  23. <script type="text/javascript" src="<%=path%>/libs/js/nav/pageArrow.js"></script>
  24. <!--箭头分页end-->
  25. <SCRIPT type="text/javascript">
  26. var setting = {
  27. async: {
  28. enable: true,
  29. dataType: 'JSON',
  30. //返回的JSON数据的名字
  31. dataName: 'treeNodes',
  32. url: getUrl
  33. },
  34. callback: {
  35. //beforeExpand: beforeExpand,
  36. onAsyncSuccess: onAsyncSuccess,
  37. onAsyncError: onAsyncError
  38. }
  39. };
  40. var zNodes =[
  41. {id:0,name:"分页测试",isParent:true,open:true},
  42. {id:1,name:"节点1",parentId:0},
  43. {id:2,name:"节点2",parentId:0},
  44. {id:3,name:"节点3",parentId:0},
  45. {id:4,name:"节点4",parentId:0},
  46. {id:5,name:"节点5",parentId:0},
  47. {id:6,name:"节点6",parentId:0},
  48. {id:7,name:"节点7",parentId:0},
  49. {id:8,name:"节点8",parentId:0},
  50. {id:9,name:"节点9",parentId:0},
  51. {id:10,name:"节点10",parentId:0}
  52. ];
  53. var curPage = 0;
  54. function getUrl(treeId, treeNode) {
  55. //var param = "id="+ treeNode.id +"_"+curPage +"&count="+Number($("#pager").attr("pageSize")),
  56. //var param="id=11&name=节点11";
  57. return "<%=path%>/getPagedTree.action?fromIndex="+curPage;
  58. }
  59. function goPage() {
  60. var zTree = $.fn.zTree.getZTreeObj("treeDemo");
  61. var node = zTree.getNodeByParam("id", 0, null);
  62. zTree.reAsyncChildNodes(node, "refresh");
  63. }
  64. function beforeExpand(treeId, treeNode) {
  65. if (treeNode.page == 0) treeNode.page = 1;
  66. return !treeNode.isAjaxing;
  67. }
  68. function onAsyncSuccess(event, treeId, treeNode, msg) {
  69. }
  70. function onAsyncError(event, treeId, treeNode, XMLHttpRequest, textStatus, errorThrown) {
  71. var zTree = $.fn.zTree.getZTreeObj("treeDemo");
  72. alert("异步获取数据出现异常。");
  73. treeNode.icon = "";
  74. zTree.updateNode(treeNode);
  75. }
  76. function initComplete(){
  77. $.fn.zTree.init($("#treeDemo"), setting, zNodes);
  78. $("#pager").attr("total",100);
  79. $("#pager").render();
  80. $("#pager").bind("pageChange",function(e,idx){
  81. curPage=idx;
  82. goPage();
  83. })
  84. }
  85. </SCRIPT>
  86. </head>
  87. <body>
  88. <div class="box1" panelWidth="800">
  89. <div style="width:200px;height:300px;border:solid 1px #cccccc;overflow-x:hidden;overflow-y:auto;">
  90. <ul id="treeDemo" class="ztree"></ul>
  91. </div>
  92. <div class="pageArrow" keepDefaultStyle="true" id="pager"></div>
  93. </div>
  94. </body>
  95. </html>