|
<% @ Page language = "java" import = "java. util. *" pageEncoding = "UTF-8" %>
<%
String path = request. getContextPath ();
String basePath = request. getScheme () + "://"
+ Request. getServerName () + ":" + request. getServerPort ()
+ Path + "/";
%>
<! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN">
<Html>
<Head>
<Title> Ztree </title>
<Meta http-equiv = "keywords" content = "keyword1, keyword2, keyword3">
<Meta http-equiv = "description" content = "this is my page">
<Meta http-equiv = "content-type" content = "text/html; charset = UTF-8">
<Link rel = "stylesheet" type = "text/css"
Href = "<% = request. getContextPath () %>/css/zTreeStyle.css">
<Script type = "text/javascript"
Src = "<% = request. getContextPath () %>/js/jquery-1.9.1.min.js"> </script>
<Script type = "text/javascript"
Src = "<% = request. getContextPath () %>/js/jquery. ztree. core. js"> </script>
<Script type = "text/javascript"
Src = "<% = request. getContextPath () %>/js/jquery. ztree. excheck. min. js"> </script>
<Script type = "text/javascript">
/**
* Asynchronous loading means that when you click to expand a tree node,
* Requests the background action to return the subnode of The clicked node.
* Data is loaded.
*/
Var setting = {
Data :{
Key :{
Name: "catalogName"
},
SimpleData :{
Enable: true,
IdKey: "catalogId ",
PIdKey: "parentId ",
}
},
Async :{
Enable: true,
Url: "ztree/list. ht ",
AutoParam: ["catalogId", "catalogName"],
DataFilter: filter
// Filter the returned result asynchronously
},
Callback :{
// BeforeAsync: zTreeBeforeAsync, // get the relevant information before loading events asynchronously
OnAsyncSuccess: zTreeOnAsyncSuccess, // fun loaded asynchronously
AOnAsyncError: zTreeOnAsyncError, // load the wrong fun
BeforeClick: beforeClick, // capture the event callback function before clicking a node
OnRightClick: zTreeOnRightClick
}
};
// TreeId is treeDemo. This method is used after asynchronous loading.
Function filter (treeId, parentNode, childNodes ){
If (! ChildNodes)
Return null;
ChildNodes = eval (childNodes );
Return childNodes;
}
// Click a node to trigger the event
Function beforeClick (treeId, treeNode ){
If (! TreeNode. isParent ){
Alert ("Select parent node ");
Return false;
} Else {
Return true;
}
}
// This method is used when asynchronous loading fails.
Function zTreeOnAsyncError (event, treeId, treeNode ){
Alert ("asynchronous loading failed! ");
}
// This method is used for asynchronous loading.
Function zTreeOnAsyncSuccess (event, treeId, treeNode, msg ){
}
// Right-click the event
Function zTreeOnRightClick (){
Alert ("asdas ");
}
/********** When you click the parent node, the controller will be accessed asynchronously, pass the id *************/
Var zNodes = [];
$ (Document). ready (function (){
$. Fn. zTree. init ($ ("# treeDemo"), setting, zNodes );
});
</Script>
</Head>
<Body>
<Div style = "height: 600px; width: 98%">
<Div style = "height: 600px; width: 20%; border: 1px solid #999999; float: left">
<Ul id = "treeDemo" class = "ztree"> </ul>
</Div>
<Div style = "height: 600px; width: 79.5%; border: 1px solid #999999; float: left; overflow: auto">
<Iframe id = "testIframe" name = "testIframe" frameborder = 0 scrolling = auto width = 90% height = 580px src = "ztree/welcome. ht"> </iframe>
</Div>
</Div>
</Body>
</Html> |