在javascript中写下如下代码:
// Add a dynamic tab (With toolbar).
var mainTabStrip = Ext.getCmp('<%= mainTabStrip.ClientID %>');
var tabID = 'dynamic_added_tab' + node.id.replace('__', '-');
mainTabStrip.addTab({
'id': tabID,
'url': href,
'title': node.parentNode.text + ' -> ' + node.text,
'closable': true,
'bodyStyle': 'padding:0px;',
'iconCls': 'icon_' + href.replace(/[^.]+\./, ''),
'tbar': new Ext.Toolbar({
items: ['->', sourcecodeButton, '-', openNewWindowButton]
})
});
}
// Click the tree node.
treeMenu.on('click', function (node, event) {
if (node.isLeaf()) {
var href = node.attributes.href;
// Modify the location of current url.
window.location.href = '#' + href;
addExampleTab(node);
// Don't response to this tree node's default behavior.
event.stopEvent();
}
});
(function pageFirstLoad() {
var currentHash = window.location.hash.substr(1);
var level1Nodes = treeMenu.getRootNode().childNodes;
for (var i = 0; i < level1Nodes.length; i++) {
var level2Nodes = level1Nodes[i].childNodes;
for (var j = 0; j < level2Nodes.length; j++) {
var currentNode = level2Nodes[j];
if (currentNode.attributes.href === currentHash) {
level1Nodes[i].expand();
// We must retrieve this node again, because currentNode doesn't has parentNode property.
var foundNode = treeMenu.getNodeById(currentNode.id);
foundNode.select();
addExampleTab(foundNode);
return;
}
}
}
})();
|