PDA

View Full Version : [Solved]this.tree.on is not a function



ChristianH
22 Nov 2007, 6:40 PM
Hi,

I am getting the error:

this.tree.on is not a function

When running this code:


App.BaseProductMngr = Ext.extend(Ext.app.Module, {
id : 'product-manager-win',

init : function(){
this.launcher = {
text: 'Base Product Manager',
iconCls:'base-product',
handler : this.createWindow,
scope: this
}
},

createWindow : function(){
var desktop = this.app.getDesktop();
var win = desktop.getWindow('product-manager-win');
if(!win){
var winWidth = desktop.getWinWidth() / 1.1;
var winHeight = desktop.getWinHeight() / 1.1;

win = desktop.createWindow({
id: 'product-manager-win',
title:'Base Product Manager',
width:winWidth,
height:winHeight,
x:desktop.getWinX(winWidth),
y:desktop.getWinY(winHeight),
iconCls: 'base-product',
shim:false,
animCollapse:false,
constrainHeader:true,
minimizable:true,
maximizable:true,

layout: 'border',
tbar:[{
text: 'Add Category',
tooltip:{title:'Add a New Category', text:'Add a category to the base-product listing'},
iconCls:'bpm-add-cat'
},{
text: 'Edit Category',
tooltip:{title:'Edit a Category', text:'Change the properties of the current category'},
iconCls:'bpm-edit-cat'
},{
text: 'Remove Category',
tooltip:{title:'Edit a Category', text:'Edit the currently selected category'},
iconCls:'bpm-rem-cat'
},'-',{
text: 'Add New Product',
tooltip:{title:'Add a New Product', text:'Add a new product to the selected category'},
iconCls:'bpm-add-item'
},{
text: 'Edit Product',
tooltip:{title:'Edit a Product', text:'Edit the selected product'},
iconCls:'bpm-edit-item'
},{
text: 'Remove Product',
tooltip:{title:'Remove a Product', text:'Remove the selected product'},
iconCls:'bpm-rem-item'

}],
items:[{
region:'west',
autoScroll:true,
collapsible:true,
cmargins:'0 0 0 0',
margins:'0 0 0 0',
split:true,
title:'Categories',
width:parseFloat(winWidth*0.3) < 201 ? parseFloat(winWidth*0.3) : 200,
items: [
new Ext.tree.TreePanel({
id:'cat-list',
title: 'Active',
loader: new Ext.tree.TreeLoader({
dataUrl:'./applications/base-product-manager/app.php',
baseParams: {req:'sidebar', type:'active'}
}),
rootVisible:false,
lines:false,
autoScroll:true,
on: [{
click: function()
{
alert('foo')
}
}],
tools:[{
id:'refresh',
on:{
click: function(){
var tree = Ext.getCmp('cat-list');
tree.body.mask('Loading', 'x-mask-loading');
tree.root.reload();
tree.root.collapse(true, false);
setTimeout(function(){ // mimic a server call
tree.body.unmask();
tree.root.expand(true, true);
}, 1000);
}
}
}],
root: new Ext.tree.AsyncTreeNode({
text:''
})
}),
new Ext.tree.TreePanel({
id:'cat-list2',
title: 'In-Active',
loader: new Ext.tree.TreeLoader({
dataUrl:'./applications/base-product-manager/app.php',
baseParams: {req:'sidebar', type:'in-active'}
}),
rootVisible:false,
lines:false,
autoScroll:true,
tools:[{
id:'refresh',
on:{
click: function(){
var tree = Ext.getCmp('cat-list2');
tree.body.mask('Loading', 'x-mask-loading');
tree.root.reload();
tree.root.collapse(true, false);
setTimeout(function(){ // mimic a server call
tree.body.unmask();
tree.root.expand(true, true);
}, 1000);
}
}
}],
root: new Ext.tree.AsyncTreeNode({
text:''
})
})
]

},{
region:'center',
border:false,
layout:'border',
margins:'0 0 0 0',
items:[{
region:'north',
elements:'body',
title:'Products',
html: '<b>Please click on a category, to the left to start',
height:winHeight*0.3,
region:'center',
split:false,
items:
new Ext.grid.EditorGridPanel({
border:false,
ds: new Ext.data.Store({
reader: new Ext.data.ArrayReader({}, [
{name: 'Product Name'},
{name: 'price', type: 'float'},
{name: 'size', type: 'float'},
{name: 'weight', type: 'float'}
]),
data: Ext.grid.dummyData
}),
cm: new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer(),
{header: "Product Name", width: 120, sortable: true, dataIndex: 'company'},
{header: "Price", width: 70, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'price'},
{header: "# Ordered", width: 70, sortable: true, dataIndex: 'change'},
{header: "weight", width: 70, sortable: true, dataIndex: 'pctChange'}
]),

viewConfig: {
forceFit:true
}
})
}]
}]
});
}
win.show();
}
});



For the life of me, I can't figure it out, as I've googled, and found examples to work that way... What am I doing wrong?


Thanks,
Christian

ChristianH
22 Nov 2007, 7:35 PM
...And, I forgot something... this is Ext 2, I posted it in the wrong thread!

-Christian

tryanDLS
22 Nov 2007, 8:03 PM
This piece is wrong


on: [{
click: function()
{
alert('foo')
}
}],


The config entry is 'listeners', not 'on' and it's not an array


listeners: {
click: function() {alert('foo')}
}

ChristianH
23 Nov 2007, 8:15 PM
Danke! Work like a charm.