PDA

View Full Version : [FIXED][3.1pre] Adding nodes to an existing TreeGrid



nextdigital
9 Dec 2009, 4:28 PM
If this is the wrong way to add nodes to an existing treegrid, then please close this bug and tell me how... This is the method I use for TreePanel so I figured it would be the same for TreeGrid.

Screenshots should tell the story.



Ext.onReady(function(){
var treegrid = new Ext.ux.tree.TreeGrid({
tbar: [{
text: 'Create Folder',
scope: this,
handler: function(){
var newNode = new Ext.tree.AsyncTreeNode({
errors:0,
text:"New Folder",
name:"New Folder",
recipients:0,
created:1260287731,
duplicates:0,
unsubscribed:0,
active:0,
iconCls:"icon-list",
bounced:0,
sent:0,
children: []
});
treegrid.getRootNode().appendChild(newNode);
}
}],
width: 500,
height: 300,
renderTo: Ext.getBody(),
enableDD: true,
columns:[{
id: 'name',
header: 'List Names',
width: 200,
sortable: true,
dataIndex: 'name'
},{
id: 'recipients',
header: 'Recipients',
width: 75,
sortable: true,
dataIndex: 'recipients'
},{
id: 'created',
header: 'Created',
width: 75,
sortable: true,
dataIndex: 'created'
},{
id: 'sent',
header: 'Sent',
width: 75,
sortable: true,
dataIndex: 'sent'
}]
});

var json = [{
"errors":0,
"leaf":true,
"name":"My List",
"recipients":0,
"created":1260287731,
"duplicates":0,
"unsubscribed":0,
"active":0,
"iconCls":"icon-list",
"bounced":0,
"sent":0
},{
"errors":0,
"name":"A Folder",
"recipients":0,
"created":1260287731,
"duplicates":0,
"unsubscribed":0,
"active":0,
"iconCls":"icon-list",
"bounced":0,
"sent":0,
"children": [{
"errors":0,
"leaf":true,
"name":"A child List",
"recipients":0,
"created":1260287731,
"duplicates":0,
"unsubscribed":0,
"active":0,
"iconCls":"icon-list",
"bounced":0,
"sent":0
}]
}]

var root = new Ext.tree.AsyncTreeNode({
text: 'Lists',
draggable: false,
children: json,
id: 'root'
});
treegrid.setRootNode(root);
});

TommyMaintz
9 Dec 2009, 4:44 PM
Thanks for the example. I'll look into this ASAP and make sure these different methods of adding all work.

TommyMaintz
9 Dec 2009, 5:41 PM
This has been fixed in SVN in revision: #5762

Please let me know if you run into any other issues.

nextdigital
9 Dec 2009, 5:58 PM
seems pretty stable to me, tommy

good work!

Krazycaptain
26 May 2010, 4:23 AM
I have a requirement to create a folder in the existing Tree structure(treePanel).I am giving a pop up window to enter the name of the folder & then i need to create the folder & save the new tree structure on the server.
Its urgent..so plz help fast