-
8 Mar 2012 12:25 PM #1
Answered: flow layout button panel
Answered: flow layout button panel
I am trying to make a panel that contains a dynamic number of buttons. I would like to layout the buttons as if they were 'inline' HTML elements in a flow layout. In other words, I would like the first button to be positioned at the top-left corner of the panel, the next button to its right and so on. If a button overflows the right edge of the panel, I would like to 'line break' to the next 'line' in the panel and begin laying out the remaining buttons on the next line. Is there an existing layout manager that does this or is there some sample code that does this?
Thanks.
-
Best Answer Posted by mitchellsimoens
The cls config expects a CSS class name
And then in your CSS file:Code:cls : 'button-inline'
Code:.button-inline { display : inline-block; }
-
8 Mar 2012 12:32 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,120
- Vote Rating
- 453
- Answers
- 3160
Two options, if you want to have flex sizing then you can use hbox layout. Other wise a more performant way is to give the buttons some CSS like display : inline-block;
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
8 Mar 2012 2:19 PM #3
I decided to try your CSS suggestion so I configured my buttons as follows:
{
xtype: 'button',
text: 'abc',
maxWidth: '50px',
margin: 5,
cls: 'display : inline-block;'
},
When I specified no layout on the containing panel, the buttons were displayed one per line. When I set the layout of the containing panel to 'hbox', but the buttons did not line-break to the next line but were laid out in a single line that extended off the right edge of the screen.
-
8 Mar 2012 2:26 PM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,120
- Vote Rating
- 453
- Answers
- 3160
The cls config expects a CSS class name
And then in your CSS file:Code:cls : 'button-inline'
Code:.button-inline { display : inline-block; }Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
8 Mar 2012 6:04 PM #5
Fixed!
Fixed!
That did it! Thanks a lot for your help.


Reply With Quote