View Full Version : Ext.Button label should be updated dynamically.

10 Jan 2011, 9:11 AM
I have a Ext.Window with a button name OK.
Whenever I add a record to a database the label of the button should changes like"more data available".

I am able to get the data from DB and store it in session.

how to modify the label of the button?

10 Jan 2011, 1:46 PM
Something like.

Ext.getCmp('myButtonId').setText('more data available');

10 Jan 2011, 4:24 PM
Please don't use getCmp...

btn.setText("some text");

11 Jan 2011, 1:05 AM
Please don't use getCmp...

btn.setText("some text");
What's wrong with getCmp?

I thought it was a generally acceptable method?

http://www.sencha.com/forum/showthread.php?62719-Ext.getCmp-and-Best-Practices/ (http://www.sencha.com/forum/showthread.php?62719-Ext.getCmp-and-Best-Practices/page2)

11 Jan 2011, 1:18 AM
There is nothing wrong with using getCmp, as long as you are aware of the problems associated with it.

See this screencast (http://www.sencha.com/forum/showthread.php?109307-Screencast-quot-The-dangers-of-Ext.getCmp()-quot).

11 Jan 2011, 5:06 AM
If you are doing debugging, I can see where getCmp has uses but I am with this camp (http://www.sencha.com/forum/showthread.php?103569-Ext.getCmp-and-developers-using-it-as-a-crutch&highlight=getcmp+crutch). The only reason I am against it is because IMO it goes against good OOP practices. Everything I do is reusable and setting static IDs goes against this. I used to rely on getCmp and creating different IDs but I have learned other and better ways.

11 Jan 2011, 6:11 AM
So far getCmp has proved very useful and a rapid way of coding my app. I can see the arguments for not using it. I am however confident that my ID's are unique and i'm happy to parse the code base once in a while to ensure this is still true. My main concern would be the execution stack time overhead and increase in code base size. Iím sure getCmp it will come back and bight me however :)

Update: thinking about thisÖ I do make a habit of setting varís based on the getCmp so that I donít have to keep executing getCmp.. It's probably not best practice either way :">

11 Jan 2011, 9:50 AM
Kindly let me know,
1.) Is there any way like the Ext.Button sends Ajax request for every 10 seconds to the server.