PDA

View Full Version : Shouldn't this work?



bobthebuilder
30 Oct 2009, 10:36 AM
Ext.onReady(function(){

TestTree = Ext.extend(Ext.tree.TreePanel, {
bbar: [{
text: 'test'
}]
})

Ext.reg('testtree', TestTree);

var viewport = new Ext.Viewport({
layout: 'border',
items: [{
region: 'west',
xtype: 'testtree',
width: 200,
root: {
text: 'Root Node'
}
},{
region: 'center',
html: 'empty center'
}]
});
});
Take out the bbar from the extend call and put it in the viewport item directly and it works. Otherwise, I get from firebug:



uncaught exception: [Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER)" nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)" location: "JS frame :: ext-all-debug.js :: anonymous :: line 21692" data: no]
adapter/ext/ext-base.js
Line 7


I am using Firefox 3.5 and ExtJS 3.0.0

13 Nov 2009, 6:45 AM
At first glance, this issue stems from Panel.js

a simple test case:



var p = Ext.extend(Ext.Panel, {
tbar: [{
text: 'test',
handler : this.test
}],
test : function() {
console.info('here');
}
})

var t = new p();

new Ext.Window({
layout: 'fit',
height : 300, width : 200,
items: t
}).show()

13 Nov 2009, 6:47 AM
The following does work, however:



var p = Ext.extend(Ext.Panel, {
constructor : function() {
this.tbar = [{
text: 'test',
handler : this.test
}];
this.constructor.superclass.constructor.apply(this, arguments);
},

test : function() {
console.info('here');
}
})

var t = new p({
region: 'west',
xtype: 'testtree',
width: 200,
root: {
text: 'Root Node'
}
});
new Ext.Window({
layout: 'fit',
height : 300, width : 200,
items: t
}).show()