View Full Version : Select first children of TreePanel

4 May 2012, 12:18 PM
Hello together

Why doesn't the following code work in Ext JS 4.1 final?

Ext.onReady(function() {
var store = Ext.create('Ext.data.TreeStore', {
root: {
expanded: true,
children: [
{ text: "Item 1", leaf: true },
{ text: "Item 2", leaf: true }

var tree = Ext.create('Ext.tree.Panel', {
store: store,
rootVisible: false

Ext.create('Ext.container.Viewport', {
layout: 'border',
items: [{
region: 'west',
collapsible: true,
title: 'TreePanel',
width: 200,
split: true,
layout: 'fit',
items: [

In Ext JS 4 RC3 the above code works as expected.

How can I achieve that the 1st children in the TreePanel will be selected in Ext JS 4.1 final?

Thanks for your help!

Kind regards, extjser12

4 May 2012, 3:17 PM
Some solutions for your case:
1. Specifying a field for getPath() and setPath(). One thing to remember is that this field should make the path unique. So it's better to define id for each node and use that field (default field is determined by idProperty)

tree.selectPath(tree.getRootNode().getChildAt(0).getPath('text'), 'text');

2. Use SelectionModel