nicrox
23 Aug 2007, 6:25 PM
hi,
I have:
an Ext.Toolbar.MenuButton(can't find any docos for this one guys)
an Ext.tree.TreePanel with a root node
2 function handlers addChildren and testI'm trying to achieve this:
click on a tool bar->menu->item
render tree with new childrene.g. click item 1 -> tree rendered with 1 item
click item 2 -> tree rendered with 2 items
click item 3 -> tree rendered with 3 items
Here's my code:
var root = new Ext.tree.AsyncTreeNode({
id : 'node',
text: 'Ext JS',
draggable:false,
expanded : true,
icon : './images/example.gif',
qtip : 'node',
cls : 'nodes'
});
var tree = new Ext.tree.TreePanel(tree_div, {
animate:true,
containerScroll: true,
rootVisible: false,
lines: false
});
tree.setRootNode(root);
var menu1 = new Ext.Toolbar.MenuButton({
text: 'menu1',
hidden: false,
menu: {items:[
{ text: '1st line',
id: '11',
handler: addChildren(1)
}, '-',
{ text: '2nd line',
id: '12',
handler: addChildren(2)}, '-',
{text: '3rd line',
id: '13',
handler: addChildren(3)}
]}
});
function addChildren(qty){
for(var i=0; i<qty; i++){
child[i] = new Ext.tree.AsyncTreeNode({
id : 'node'+i,
leaf : true,
text: 'Ext JS'+i,
draggable:false,
expanded : true,
qtip : 'node'+i,
cls : 'nodes'+i,
expanded : false
});
}
root.appendChild(child);
tree.render();
root.expand();
}
function test (item) {
Ext.MessageBox.alert(item.text+' Was Clicked', 'you clicked'+item.text, item.text);
}
Problem:
As soon as I refresh browser, tree is being rendered(function being called without anyclick).
Although, I have another function test which is only executed when a click has been happened.
Any suggestion is appreciated
I have:
an Ext.Toolbar.MenuButton(can't find any docos for this one guys)
an Ext.tree.TreePanel with a root node
2 function handlers addChildren and testI'm trying to achieve this:
click on a tool bar->menu->item
render tree with new childrene.g. click item 1 -> tree rendered with 1 item
click item 2 -> tree rendered with 2 items
click item 3 -> tree rendered with 3 items
Here's my code:
var root = new Ext.tree.AsyncTreeNode({
id : 'node',
text: 'Ext JS',
draggable:false,
expanded : true,
icon : './images/example.gif',
qtip : 'node',
cls : 'nodes'
});
var tree = new Ext.tree.TreePanel(tree_div, {
animate:true,
containerScroll: true,
rootVisible: false,
lines: false
});
tree.setRootNode(root);
var menu1 = new Ext.Toolbar.MenuButton({
text: 'menu1',
hidden: false,
menu: {items:[
{ text: '1st line',
id: '11',
handler: addChildren(1)
}, '-',
{ text: '2nd line',
id: '12',
handler: addChildren(2)}, '-',
{text: '3rd line',
id: '13',
handler: addChildren(3)}
]}
});
function addChildren(qty){
for(var i=0; i<qty; i++){
child[i] = new Ext.tree.AsyncTreeNode({
id : 'node'+i,
leaf : true,
text: 'Ext JS'+i,
draggable:false,
expanded : true,
qtip : 'node'+i,
cls : 'nodes'+i,
expanded : false
});
}
root.appendChild(child);
tree.render();
root.expand();
}
function test (item) {
Ext.MessageBox.alert(item.text+' Was Clicked', 'you clicked'+item.text, item.text);
}
Problem:
As soon as I refresh browser, tree is being rendered(function being called without anyclick).
Although, I have another function test which is only executed when a click has been happened.
Any suggestion is appreciated