Newer
Older
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Fancytree - Example: columnview</title>
<script src="//code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<link href="../src/skin-lion/ui.fancytree.css" rel="stylesheet">
<script src="../src/jquery.fancytree.js"></script>
<script src="../src/jquery.fancytree.columnview.js"></script>
<!-- Start_Exclude: This block is not part of the sample code -->
<link href="../lib/prettify.css" rel="stylesheet">
<script src="../lib/prettify.js"></script>
<link href="sample.css" rel="stylesheet">
<script src="sample.js"></script>
<!-- End_Exclude -->
<style type="text/css">
table.fancytree-ext-columnview {
border-collapse: collapse;
width: 100%;
}
table.fancytree-container tbody tr td{
max-width: 300px; /* width does not work */
}
span.fancytree-node{
white-space: nowrap; /* prevent long lines to wrap */
overflow: hidden;
-o-text-overflow: ellipsis;
-ms-text-overflow: ellipsis;
text-overflow: ellipsis;
/*
display: inline;
overflow-wrap: break-word;
word-wrap: break-word;
word-break: break-all;
*/
}
span.fancytree-title{
display: inline; /* prevent long lines to start with a break after the icon */
}
span.selTag{
border: 1px outset #dec;
display: inline-block;
padding: 0 5px;
margin: 1px 5px;
background-color: #dec;
border-radius: 5px;
cursor: pointer;
}
span.selTag button.close{
border: 1px solid transparent;
border-radius: 4px;
padding: 0px 1px 2px 1px;
margin-left: 8px;
background-color: transparent;
visibility: hidden;
}
span.selTag:hover button.close{
border-color: gray;
background-color: #f99;
visibility: visible;
}
</style>
<!-- Add code to initialize the tree when the document is loaded: -->
<script type="text/javascript">
$(function(){
// Attach the fancytree widget to an existing <div id="tree"> element
// and pass the tree options as an argument to the fancytree() function:
$("#columnview").fancytree({
extensions: ["columnview"],
checkbox: true,
source: {
url: "ajax-tree-plain.json"
},
lazyLoad: function(event, data) {
data.result = {url: "ajax-sub2.json"};
},
activate: function(event, data) {
$("td#preview").text("activate " + data.node);
},
select: function(event, data) {
// create a tag, when node is selected
var node = data.node;
$("span#tag-" + node.key).remove();
if(node.selected){
$("<span>", {
id: "tag-" + node.key,
text: node.title,
"class": "selTag"
})
.data("key", node.key)
.append("<button class='close'>×</button>")
.appendTo($("td#tags"));
}
}
});
$("td#tags").on("click", "button.close", function(e){
// Bind live handler that deselects the node when user clicks 'x' of a tag
var key = $(e.target).parent().data("key"),
node = $(":ui-fancytree").fancytree("getNodeByKey", key);
node.setSelected(false);
return false; // do not bubble and trigger span click
}).on("click", "span.selTag", function(e){
// Bind live handler that activates the node, when tag is clicked
var key = $(e.target).data("key"),
node = $(":ui-fancytree").fancytree("getNodeByKey", key);
node.setActive();
});
});
</script>
</head>
<body class="example">
<h1>Example: 'columnview' extension</h1>
<div class="description">
<p>
Display tree data in a column view as known from Apple Macintosh / OSX.
</p>
<p>
<b>Status</b>: experimental
</p>
</div>
<div>
<label for="skinswitcher">Skin:</label> <select id="skinswitcher"></select>
</div>
<!-- Add a <table> element where the tree should appear: -->
<table id="columnview">
<colgroup>
<col width="300px"></col>
<col width="300px"></col>
<col width="300px"></col>
</colgroup>
<thead>
<tr> <th>1</th> <th>2</th> <th>3</th> </tr>
</thead>
<tbody>
<tr> <td>?</td> <td>?</td> <td>?</td> </tr>
<tr> <td id="tags" colspan="3">Selected nodes: </td> </tr>
<tr> <td id="preview" colspan="3">preview</td> </tr>
</tbody>
</table>
<!-- Start_Exclude: This block is not part of the sample code -->
<hr>
<p class="sample-links no_code">
<a class="hideInsideFS" href="https://github.com/mar10/fancytree">jquery.fancytree.js project home</a>
<a class="hideOutsideFS" href="#">Link to this page</a>
<a class="hideInsideFS" href="index.html">Example Browser</a>
<a href="#" id="codeExample">View source code</a>
</p>
<pre id="sourceCode" class="prettyprint" style="display:none"></pre>
<!-- End_Exclude -->
</body>
</html>