PDA

View Full Version : Using ID's inside extensions



logicmedia
4 May 2010, 7:57 AM
Hi all,

I have started playing with extensions and have a issue where I'm a bit uncertain what to do. How is ID's handled inside an extension. Take the example where I extend a grid and preconfigures it with a store and a toolbar. When a row is clicked I want to enable and disable buttons in the toolbar. I don't have a logical reference to the buttons so the obvious is to give them an ID and get the object using Ext.getCmp().

But what happens if I use the extension multiple times on the same page. Wouldn't I have multiple buttons with the same id?? How is this handled? Is there a better way to reference my objects inside the extension (in this case the toolbar buttons)

Could anybody shed some light on this, it would be much appriciated.

Regards,

Thomas

CrazyEnigma
4 May 2010, 8:21 AM
My thoughts are to use: itemId, but you can't use Ext.getCmp() for this.

cnelissen
4 May 2010, 8:49 AM
You should define the toolbar as a node of your newly extended object. Then you can target it from both within the class, and also outside the class. Typically you want to avoid using ID's on any class that you create for the reason you suggested.

wm003
5 May 2010, 6:07 AM
i would code the extension that way:

buttonnid = widgetid+buttonid;