PDA

View Full Version : Reg: Refering to id



sreekanthjup
7 Aug 2009, 10:46 PM
Hi,

I am a naive user of extjs, i have been trying to create some form in which i have a button defined as configuration object for a panel. If i want to set it to visible = false, i could see setVisible(<boolean>) function in api, but when i refer to

<button_id>.setVisible(false); where <button_id> refers to the id of the button.

its not working, where as if i seperately create a button by declaring it like:

var btn = new Ext.Button({ .... }); and say btn.setVisible(false); it works.

My question is without declaring a button explicitly how can we refer to the properties of button or any such component?

Regards,
Sreekanth

Animal
7 Aug 2009, 11:35 PM
You need the instance of the Button.

use Ext.getCmp(), or just keep a reference to it in a var from when you created it.

Just thinking that a var named after the ID you gave a Component is going to pop into existence is strange.

sreekanthjup
8 Aug 2009, 1:47 AM
Thanks Animal, Its working... it was so easy, i was packing my whole code with var declarations, this will greatly reduce the loc for me now and is good way of preventing over heaping of browser memory.