-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtree.js
90 lines (82 loc) · 2.29 KB
/
tree.js
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
Ext.onReady(function () {
//we want to setup a model and store instead of using dataUrl
Ext.define('Task', {
extend: 'TreeNode',
fields: [
{ name: 'name', type: 'string' },
{ name: 'duration', type: 'string' }
]
});
var store = Ext.create('FixedTreeStore', {
buffered: true,
model: 'Task',
isFillingRoot: false,
proxy: {
type: 'memory'
}
});
function generateTaskData() {
var arr = [],
i, j, k,
cn, cn2;
for (var i = 1; i < 10; i++) {
cn = [];
for (j = 1; j < 10; j++) {
cn2 = [];
for (k = 1; k < 10; k++) {
cn2.push({
name: 'Child task ' + String(i) + String(j) + String(k),
duration : i,
leaf: true
});
}
cn.push({
name: 'Child task ' + String(i) + String(j),
duration : i,
expanded: true,
children: cn2
});
}
arr.push({
name: 'Root task #' + i,
duration : i,
children: cn,
expanded: true
});
}
return arr;
}
Ext.create('FixedTreePanel', {
title: 'Core Team Projects',
width: 500,
height: 300,
renderTo: Ext.getBody(),
collapsible: true,
useArrows: true,
rootVisible: false,
store: store,
multiSelect: true,
singleExpand: true,
//the 'columns' property is now 'headers'
columns: [{
xtype: 'treecolumn', //this is so we know which column will show the tree
text: 'Task',
width: 200,
sortable: true,
dataIndex: 'name',
locked: true
}, {
text: 'Duration',
width: 150,
dataIndex: 'duration',
sortable: true
}, {
text: 'Some unlocked column',
width: 150,
dataIndex: 'name',
sortable: true
}]
});
store.proxy.data = generateTaskData();
store.load();
});