View Full Version : Extension with combobox in toolbar only renders on one instance

19 Apr 2011, 4:42 PM
Ok, pretty sure that there is going to be a simple solution to this, but here goes:

I am writing an extension to the panel class to create a "log tail" panel. The panel has a toolbar with start/stop buttons to control the tail.

Everything work great.

Now, I want to add a combobox to be able to control the length of the tail (10, 20, 30, etc), so I added a combo to the toolbar and here is the issue. Only the last rendered instance of the extension gets a combobox. I even stripped down my combo box to a simple one incase it was a datastore issue...nope!

Here is the extension:

Ext.app.LogTail = Ext.extend(Ext.Panel, {
url: 'foo',
interval: 2000,
runner: new Ext.util.TaskRunner(),
update: function(p){
url: p.url,
callback: function() {
//Insert Awesome Code Here
scope: p
xtype: 'tbbutton',
text: 'Start',
handler: function(btn){
var p = btn.ownerCt.ownerCt;
if (typeof p.task === "undefined"){
p.task = {
run: p.update,
interval: p.interval,
args: [p]
text: 'Stop',
xtype: 'tbbutton',
handler: function(btn, event){
var p = btn.ownerCt.ownerCt;
if (typeof p.task !== "undefined"){
}, new Ext.form.ComboBox()]

At first I was instantiating multiple instances inside of a tab panel and thought deferred rendering might be the culprit, but I tried a border layout using this extension for both center and south and got the same result. The last panel rendered gets the combo. Is this some sort of singleton kind of thing going on here?

Help please!

19 Apr 2011, 5:23 PM
Doh! Ok, so I found a similar question on SO:http://stackoverflow.com/questions/3150204/extjs-how-to-initialize-new-elements-when-extending-without-losing-scope

Long story short, what I was doing was indeed initializing a single combo that can, obviously, only exist on one panel.

Lesson learned. Hope it helps someone else ;)