O'Reilly logo

Ext JS 4 First Look by Loiane Groner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Tree panel

The tree component is much more simplified in Ext JS 4. Like grid, it is also a subclass of Ext.panel.Table. This means we can add most functionality of the grid in the tree as well.

Let's start declaring a simple tree in Ext JS 3:

new Ext.tree.TreePanel({
   renderTo: 'tree-example',
   title: 'Simple Tree',
   width: 200,
   rootVisible: false, 

   root: new Ext.tree.AsyncTreeNode({
      expanded: true,
      children: [
          { text: "Menu Option 1", leaf: true },
          { text: "Menu Option 2", expanded: true, 
             children: [
                   { text: "Sub Menu Option 2.1", leaf: true },
                   { text: "Sub Menu Option 2.2", leaf: true}
          ] },
          { text: "Menu Option 3", leaf: true }
      ]
   })
});

Now, let's see how to declare the same tree in Ext JS:

Ext.create('Ext.tree.Panel', { title: 'Simple Tree', width: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required