View Full Version : Set the button width dynamically

29 Apr 2011, 11:24 AM
I'm developing a web app for iPad and I'm new in Sencha Touch. The problem is:

The app as a sidebar and a content area [both are Ext.Panel]. The two panels have a flex .2 and .8 respectively so their width change depending on the width of viewport. The sidebar has buttons and I want to apply to them the sidebar width.
My idea is to get the sidebar width using the method getWidth() and use the returned value for the button width.
I have tried different ways but they do not work.

var buttons = [
text: 'Normal',
handler: function(){
var sideBarw = MyApp.sidePanel.getWidth();

MyApp.navBarPanel = new Ext.Panel({
defaults: {
defaults: {
xtype: 'button',
cls : 'demobtn',
flex : 1,
width: // I want the width of MyApp.navBarPanel.getWidth();
items: [{ items: buttons }]