to fix:
Code:
selectPath : function(path, attr, callback){
attr = attr || "id";
var keys = path.split(this.pathSeparator);
var v = keys.pop();
if(keys.length > 0){
var f = function(success, node){
needs to be:
Code:
selectPath : function(path, attr, callback){
attr = attr || "id";
var keys = path.split(this.pathSeparator);
var v = keys.pop();
if(keys.length > 1){
var f = function(success, node){
test case:
Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Reorder TreePanel</title>
<link rel="stylesheet" type="text/css" href="http://extjs.com/deploy/dev/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="http://extjs.com/deploy/dev/resources/css/xtheme-default.css" /><!-- LIBS -->
<script type="text/javascript" src="http://extjs.com/deploy/dev/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="http://extjs.com/deploy/dev/ext-all.js"></script>
<link rel="stylesheet" type="text/css" href="http://extjs.com/deploy/dev/examples/shared/examples.css" />
<script language="javascript" type="text/javascript">
Ext.onReady(function(){
// shorthand
var Tree = Ext.tree;
var tree = new Tree.TreePanel({
el:'tree-div',
useArrows:true,
autoScroll:true,
animate:true,
enableDD:true,
containerScroll: true,
root: {
text: 'Ext JS',
draggable:false,
id:'source'
}
});
// render the tree
tree.render();
tree.selectPath(tree.getRootNode().getPath('id'), 'id', function(success, node) {
alert('success = ' + success)
});
});
</script>
</head>
<body>
<div id="tree-div" style="overflow:auto; height:300px;width:250px;border:1px solid #c3daf9;"></div>
</body>
</html>