PDA

View Full Version : Checkbox with Tree Panel



Dark Assassin
12 Jul 2010, 2:36 AM
Hi everyone!
I'm trying to add some data in a Tree Panel...If i use the example on extjs site, everything works fine, fut when i try my data it doesn't show anything.
This is the code:

var tree = new Ext.tree.TreePanel({
title: 'My Task List',
height: 300,
width: 400,
useArrows:true,
autoScroll:true,
animate:true,
enableDD:true,
containerScroll: true,
rootVisible: false,
frame: true,
root: {
nodeType: 'async'
},

// auto create TreeLoader
//dataUrl: 'check-nodes.json',
children: [{
text: 'To Do',
cls: 'folder',
children: [{
text: 'Go jogging',
leaf: true,
checked: false
},{
text: 'Take a nap',
leaf: true,
checked: false
},{
text: 'Climb Everest',
leaf: true,
checked: false
}]
},{
text: 'Grocery List',
cls: 'folder',
children: [{
text: 'Bananas',
leaf: true,
checked: false
},{
text: 'Milk',
leaf: true,
checked: false
},{
text: 'Cereal',
leaf: true,
checked: false
},{
text: 'Energy foods',
cls: 'folder',
children: [{
text: 'Coffee',
leaf: true,
checked: false
},{
text: 'Red Bull',
leaf: true,
checked: false
}]
}]
},{
text: 'Remodel Project',
cls: 'folder',
children: [{
text: 'Finish the budget',
leaf: true,
checked: false
},{
text: 'Call contractors',
leaf: true,
checked: false
},{
text: 'Choose design',
leaf: true,
checked: false
}]
}],

listeners: {
'checkchange': function(node, checked){
if(checked){
node.getUI().addClass('complete');
}else{
node.getUI().removeClass('complete');
}
}
}
});

tree.getRootNode().expand(true);
I'm trying to adding some child node.I think that maybe i miss something.
Then i've another question about this, how could i built dynamic checked children?I mean that someone gives me a parameter(ex. Soccer) and i need to check some items(ex. Goalkeeper, Forward).
Thank you all about your patience!!!!!!

Condor
12 Jul 2010, 3:37 AM
'children' needs to be inside the root config, and your root nodeType is 'node' and not 'async'.