My favorites | Sign in
Project Home Downloads
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 222 attachment: tree-test2.html (3.3 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" >
<title>Border Layout - jQuery EasyUI Demo</title>

<script src="js/jquery-1.6.2.min.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.8.15.custom.min.js" type="text/javascript"></script>
<link href="dynatree/skin-vista/ui.dynatree.css" rel="stylesheet" type="text/css">
<script src="dynatree/jquery.dynatree.js" type="text/javascript"></script>


</head>
<body >

<div id="tree" style="align:center">
</div>


<button id="btnLoadKeyPath">Load node by path '/1/12/123'...</button>

<script>

function createTree() {
// Define default tree config options
var treeConfigOptions = {
fakeAjax : true,
title : 'Tree',
rootCollapsible: false,
keyboard: true,
keyPathSeparator: "/",
imagePath:'jquery/images/', // TODO: may need to adjust
clickFolderMode: 1, //3, //2,
checkbox: false,
selectMode: 2,
// if children are not passed by caller, this will be used as sample nodes to display
children: [
{title: "Node 1", icon:'layout_button_left.gif', isFolder: true, expand: false, key: "1",
children: [
{title: "Node 1.2", isFolder: true, "isLazy": true, expand:false, key: "12"}
]
}
],
onActivate: function(node) {
$("#echoActive").text("" + node + " (" + node.getKeyPath()+ ")");
},

onLazyRead: function(node) {
logMsg("onLazyRead(%o)", node);

if (treeConfigOptions.fakeAjax) {
var fakeJsonResult = [
{ title: 'Lazy node 1', isLazy: false, select: false, key: '123' }
];
function fakeAjaxResponse() {
return function() {
node.addChild(fakeJsonResult);
// Remove the 'loading...' status:
node.setLazyNodeStatus(DTNodeStatus_Ok);
};
}
window.setTimeout(fakeAjaxResponse(), 1500);
} else {
// Real ajax code for my application that goes to server and gets json objects
}
},

onClick: function(node, event) {
logMsg("onClick(%o, %o)", node, event);
//return false;
}
};

// render tree
var tree = $('#tree').dynatree(treeConfigOptions);

return tree;

};

$(document).ready(function(){

createTree();

$("#btnLoadKeyPath").click(function () {
alert("Selecting node");
var tree = $("#tree").dynatree("getTree");
// Make sure that node #_27 is loaded, by traversing the parents.
// The callback is executed for every node as we go:
tree.loadKeyPath("/1/12/123", function(node, status){
if(status == "loaded") {
// 'node' is a parent that was just traversed.
// If we call expand() here, then all nodes will be expanded
// as we go
node.expand();
}else if(status == "ok") {
// 'node' is the end node of our path.
// If we call activate() or makeVisible() here, then the
// whole branch will be exoanded now
node.activate();
}
});
});


});



</script>


</body>
</html>
Powered by Google Project Hosting