-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExt.ux.JumpableNestedList.js
More file actions
74 lines (74 loc) · 2.98 KB
/
Ext.ux.JumpableNestedList.js
File metadata and controls
74 lines (74 loc) · 2.98 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
Ext.ux.JumpableNestedList = Ext.extend(Ext.NestedList, {
traceSelectionPath: true,
hideSelectionPath: true,
jumpToNode: function(nodeInfo,doSelect,hideActive) {
var me = this,
tree = me.store.tree,
nodes = [],
node = nodeInfo;
if(Ext.isString(nodeInfo)) {
// do lookup of node based on id
node = tree.getNodeById(nodeInfo);
if(!nodeInfo) {
return false;
}
}
// first things first; remove existing lists and detail cards from current nested list
for(i=(me.items.length-1);i >= 1;i--){
me.remove(me.items.getAt(i));
}
// at the top level list (which we'll leave), deselect any selected records
me.items.getAt(0).deselect(me.items.getAt(0).getSelectedRecords());
// get the depth of the node
var depth = node.getDepth();
var nid = node.id;
// loop over depth, get node ids of node hierarchy
for(i=0;i<depth;i++) {
nodes.push(nid);
nid = tree.nodeHash[nid].parentNode.id;
}
// reverse the node array, and we'll build out the new lists
nodes = nodes.reverse();
var newlist,
nextlist = me.items.getAt(0),
prevlist = me.items.getAt(0),
child,
tmpnode,
curridx = 0;
nextlist = me.items.getAt(0);
// now loop over hierarchy of nodes, adding lists as we go along
for(i=0;i<nodes.length;i++) {
tmpnode = tree.getNodeById(nodes[i]);
// if it's not a leaf, we're working with a list
if(!tmpnode.leaf) {
// get the sublist
newlist = me.getSubList(tmpnode);
// add it to the nestedlist
nextlist = me.addNextCard(newlist.recordNode);
//me.layout.hideActive = true;
me.layout.setActiveItem(nextlist,"fade",me.hideSelectionPath);
if(me.traceSelectionPath) {
// get the index of the list we just added
curridx = me.items.indexOf(nextlist);
// get the one before it
prevlist = me.items.getAt(curridx-1);
// find the child node that corresponds to the item in the hierarchy
child = prevlist.getNode(tmpnode.getRecord())
// if doSelect is true, fire select on current node
prevlist.selModel.select(child)
}
}
// is a leaf; will probably want to fire onItemTap()
else {
var idx = nextlist.store.find("id",tmpnode.id);
if(me.traceSelectionPath) {
// should be the last added list
prevlist = me.items.getAt(curridx);
child = prevlist.getNode(tmpnode.getRecord())
prevlist.selModel.select(child)
}
me.onItemTap(nextlist,idx);
}
}
}
});