PDA

View Full Version : getDockedItems() and getActiveItem() methods on panel always return [object Object]



adityadevgupta
4 Jun 2011, 11:48 PM
I need to return the docked items and active item for a panel with id 'main'

for purely debugging purposes I returned the method to an alert box...so alert(Ext.getCmp('main').getDockedItems()) returns [object Object]. The same with getActiveItem().

What could be wrong? Here's my code for the panels:


home=new Ext.Panel({
id: 'home',
styleHtmlContent: true,
scroll: 'vertical',
contentEl: 'homediv',
cls: 'htmlcontent',
flex: 1
});

category=new Ext.Panel({
id: 'category',
styleHtmlContent: true,
scroll: 'vertical',
contentEl: 'category',
cls: 'htmlcontent'
//dockedItems: dockedItems
});

new Ext.Panel({
dockedItems: dockedItems,
fullscreen: true,
id: 'main',
layout: 'card',

items: [home, category]
});

mitchellsimoens
5 Jun 2011, 6:57 AM
What's in dockedItems variable? Is it an array of docked items or just one docked item as an object?

adityadevgupta
5 Jun 2011, 6:59 AM
This is my code for docked items


var dockedItems = [{
itemId: 'tb_top',
xtype: 'toolbar',
title: 'title',
ui: 'light',
dock: 'top',
items: buttonsSpecTop,
//defaults: { handler: tapHandler }
}, {
xtype: 'tabbar',
ui: 'dark',
dock: 'bottom',
items: buttonsSpecBottom,
//defaults: { handler: tapHandler }
}]


And, rather irrelevant at this point, but is there a reason a lot of the buttons / text on Sencha forums are in chinese?

AndreaCammarata
5 Jun 2011, 8:49 AM
Are you sure your alert doesn't return you



[object Object], [object Object]


instead of



[object Object]


?

I wrote a simple example on what you are asking and I've got an



[object Object], [object Object]


response.
Try it yourself by running the code below



//Application registration
Ext.regApplication({
name: 'test',
launch: function() {

var dockedItems = [{
itemId: 'tb_top',
xtype: 'toolbar',
title: 'MAGPYES',
ui: 'light',
dock: 'top',
//defaults: { handler: tapHandler }
}, {
xtype: 'tabbar',
ui: 'dark',
dock: 'bottom',
//defaults: { handler: tapHandler }
}]

//Definition of the Root Panel
var rootPanel = new Ext.Panel({
id: 'pnlMain',
fullscreen: true,
layout: "card",
dockedItems: dockedItems
});

alert(Ext.getCmp('pnlMain').getDockedItems());
}
});


Hope this helps.

mitchellsimoens
5 Jun 2011, 8:51 AM
Also, use console.log or one of the other methods on console to debug. alert is good for text but not for... anything :))

AndreaCammarata
5 Jun 2011, 8:53 AM
Also, use console.log or one of the other methods on console to debug. alert is good for text but not for... anything :))

I perfectly agree :D

adityadevgupta
5 Jun 2011, 9:09 AM
Oops..! I was actively using the console.log while debugging a recent chrome extension project..dunno what went wrong with me here :D

Sorry, I was indeed getting a response

[object Object], [object Object]

How am I to obtain the id of the docked item ? There are changes I wish to make to the docked item as part of my app.

AndreaCammarata
5 Jun 2011, 9:12 AM
Oops..! I was actively using the console.log while debugging a recent chrome extension project..dunno what went wrong with me here :D

Sorry, I was indeed getting a response

[object Object], [object Object]

How am I to obtain the id of the docked item ? There are changes I wish to make to the docked item as part of my app.

No problem :).
Please explain better what you want to do with Panel DockedItems.
Why you want to get the id of a DockedItem?

adityadevgupta
5 Jun 2011, 9:19 AM
Actually I was getting an identical response, i.e. [object Object], [object Object] from a similar method, getActiveItem() .

I needed the active item to disable buttons on the toolbar when the user is on the home card of my app .

I'm pretty confused why getDockedItems() and getActiveItem() methods always return [object Object]. Any idea on why this may be so? Maybe I misunderstand what the methods were intended to be used for.