-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTreeStore.js
More file actions
121 lines (93 loc) · 3.71 KB
/
TreeStore.js
File metadata and controls
121 lines (93 loc) · 3.71 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
114
115
116
117
118
119
120
121
Ext.define('FixedTreeStore', {
extend: 'Ext.data.TreeStore',
constructor: function (config) {
this.addEvents(
'root-fill-start',
'root-fill-end',
/**
* Will be fired on the call to `filter` method
* @event filter
* @param {Gnt.data.TaskStore} self This task store
* @param {Object} args The arguments passed to `filter` method
*/
'filter',
/**
* Will be fired on the call to `clearFilter` method
* @event clearfilter
* @param {Gnt.data.TaskStore} self This task store
* @param {Object} args The arguments passed to `clearFilter` method
*/
'clearfilter'
);
config = config || {};
// need to init the "hasListeners" hash
this.hasListeners = {};
this.callParent([config]);
},
setRootNode: function () {
var me = this;
this.tree.setRootNode = Ext.Function.createInterceptor(this.tree.setRootNode, function (rootNode) {
Ext.apply(rootNode, {
// HACK Prevent tree store from trying to 'create' the root node
phantom: false,
dirty: false
});
});
var res = this.callParent(arguments);
delete this.tree.setRootNode;
return res;
},
// much faster implementation of `fillNode` method for buffered case which uses `node.appendChild` with `suppressEvent` option
// and bypasses all the events fireing/bubbling machinery, calling the `onNodeAdded` directly
fillNode: function (node, records) {
this.isFillingNode = true;
if (node.isRoot()) {
this.isFillingRoot = true;
// console.profile('fillRoot')
// console.time('fillRoot')
this.fireEvent('root-fill-start', this, node, records);
}
var me = this,
ln = records ? records.length : 0,
i = 0, sortCollection;
if (ln && me.sortOnLoad && !me.remoteSort && me.sorters && me.sorters.items) {
sortCollection = Ext.create('Ext.util.MixedCollection');
sortCollection.addAll(records);
sortCollection.sort(me.sorters.items);
records = sortCollection.items;
}
node.set('loaded', true);
if (this.buffered) {
for (; i < ln; i++) {
var record = records[i];
record.__isFilling__ = true;
// suppress the events -------|
// \/
node.appendChild(record, true, true);
// directly call 'onNodeAdded'
this.onNodeAdded(null, record);
// register the node in tree (for `getNodeById` to work properly)
this.tree.registerNode(record);
}
} else {
for (; i < ln; i++) {
// this will prevent `getModifiedFieldNames` from doing costly
// isDate comparison 100000 times (for 1000 records)
// see the override trick for `getModifiedFieldNames`
records[i].__isFilling__ = true;
node.appendChild(records[i], false, true);
}
}
if (node.isRoot()) {
this.getRootNode().cascadeBy(function (record) {
delete record.__isFilling__;
});
this.isFillingRoot = false;
// console.profileEnd('fillRoot')
// console.timeEnd('fillRoot')
this.fireEvent('root-fill-end', this, node, records);
}
delete this.isFillingNode;
return records;
}
});