-
Notifications
You must be signed in to change notification settings - Fork 28
/
example.html
69 lines (63 loc) · 1.87 KB
/
example.html
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
<!DOCTYPE html>
<html>
<head>
<title>OrgChart Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="jquery.orgchart.css" media="all" rel="stylesheet" type="text/css" />
<style type="text/css">
#orgChart{
width: auto;
height: auto;
}
#orgChartContainer{
width: 1000px;
height: 500px;
overflow: auto;
background: #eeeeee;
}
</style>
</head>
<body>
<div id="orgChartContainer">
<div id="orgChart"></div>
</div>
<div id="consoleOutput">
</div>
<script type="text/javascript" src="jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="jquery.orgchart.js"></script>
<script type="text/javascript">
var testData = [
{id: 1, name: 'Acme Organization', parent: 0},
{id: 2, name: 'CEO Office', parent: 1},
{id: 3, name: 'Division 1', parent: 1},
{id: 4, name: 'Division 2', parent: 1},
{id: 6, name: 'Division 3', parent: 1},
{id: 7, name: 'Division 4', parent: 1},
{id: 8, name: 'Division 5', parent: 1},
{id: 5, name: 'Sub Division', parent: 3},
];
$(function(){
org_chart = $('#orgChart').orgChart({
data: testData,
showControls: true,
allowEdit: true,
onAddNode: function(node){
log('Created new node on node '+node.data.id);
org_chart.newNode(node.data.id);
},
onDeleteNode: function(node){
log('Deleted node '+node.data.id);
org_chart.deleteNode(node.data.id);
},
onClickNode: function(node){
log('Clicked node '+node.data.id);
}
});
});
// just for example purpose
function log(text){
$('#consoleOutput').append('<p>'+text+'</p>')
}
</script>
</body>
</html>