View Full Version : creating a new folder

2 Aug 2013, 1:13 AM
Just running a bit of test code on how to create a folder on a tree, (no back end functionality yet). I decided to use a treeEditor for this purpose and a context menu, everytime I create a new folder under and expanded folder, it works fine, but once I create the new folder, since it is initially empty, It appears with the +sign to the left and if I try to create a new folder under this collapsed folder with the little + sign, it keeps spinning forever. What really could be the problem

see treeEditor code below:

var treePanel = Ext.getCmp(val); var node = treePanel.getSelectionModel().getSelectedNode();
if (! this.treeEditor) {
this.treeEditor = new Ext.tree.TreeEditor(treePanel, {}, {
cancelOnEsc : true,
completeOnEnter : true,
selectOnFocus : true,
allowBlank : false,
listeners : {
complete : onCompleteAdd
node.expand(null, true, function() {
var newNodeCfg = {
text : '',
id : 'tmpFolder',
leaf : false
var newNode = node.insertBefore(newNodeCfg,
this.treeEditor.editNode = newNode;
}, this);

5 Aug 2013, 12:50 AM
can anyone help with this ?

5 Aug 2013, 8:58 AM
See if this example helps you at all:

var tree = new Ext.tree.TreePanel({
renderTo: document.body,
title: 'Sample Tree',
useArrows: true,
autoScroll: true,
animate: true,
containerScroll: true,
border: false,

root: {
text: 'root',
expanded: true,
iconCls: 'icon-folder_normal',
children: [{
text: 'child1',
expanded: true,
leaf: false,
children: []

listeners: {
contextmenu: function (node, e) {
text: 'Folder',
leaf: false,
children: [],
expanded: true

5 Aug 2013, 9:19 AM
Thanks a lot, that worked fine