View Full Version : Label width for combobox and textfields
alawi
31 Aug 2008, 5:46 PM
Hello guys,
I don't know if my eyes are failing me, but it seems that I am unable to find a method that would allow me to set the label width for the textfield and comboboxes...
I am using gxt-1.1-alpha3.
Alawi
gslender
31 Aug 2008, 10:07 PM
try this...
panel.add(textfield,new FormData(100, -1)); // 100px wide
eugenparaschiv
1 Sep 2008, 6:24 AM
And do a search before asking as well. I've asked the exact same question a while back and got the same answer. And what's funny is that I didn't do a search either, and then saw the same answer in yet another post. So things go in circles :)
Hello guys,
eugenparaschiv my apology for not searching, and yes things do come in circles..:D but the fact that this has been asked three times, implies that there is a place for improvement for the field label width API, or more examples are needed.
However, there is a slight variation in my case, I am using fieldsets with a formlayout inside a contentpanel.
so
panel.add(textfield,new FormData(100, -1)); // 100px wide
is no applicable. And when I try to add a fieldset to a formpanel, the fieldset does not show. In my humble opinion, there has to be an easy way to set the label width for the entire form, per fieldset, and per individual fields. In addition, there has to be a way of adding fieldsets to formpanels.
Sorry I am new to this, I am sure I am missing something. I am really impressed with Gxt, and I just want to see it improving ;)
gxt-1.1-alpha3
Alawi
gslender
1 Sep 2008, 7:50 PM
if the panel has FormLayout set then FormData is the right approach to get the layout setting the field width - not sure what you are doing with FieldSet (as its a panel itself) and you cannot directly add it to a formpanel (and you wouldn't).
If you want a panel with a mix of fields and fieldsets on a Panel then you use ContentPanel and layoutcontainers with formlayouts to construct the mix of fields and fieldsets but you wouldn't start with a FormPanel.
gslender,
Thanks again for the replay..
-If you use fieldset then you will not be able to change the width of the fields (unless you use css), because the method add(Component c, LayoutData formDate) is not defined for a fieldset. So first how to change the label widths in a fieldset?
-Also there is no method to check if all the fields in a fieldset are valid (like the one in formpanel)
-And I want to have the fieldsets collaped initiallly but I am unable to do so...
All I need is to add fields to a fieldset and be able to change their labelwidths, and have them collapsed at the start...
Appreicate your support gslender, :)
Alawi
gslender
1 Sep 2008, 8:53 PM
ok, so it looks as though FieldSet go do with a few improvements....
to help u out, try this...
ComponentHelper.setLayoutData(txfield, new FormData(100,-1));
As for the other things, can't help ya as ultimately you need features in FormPanel and ContentPanel that aren't in FieldSet
Nice thing about Java is that you can extend and roll your own... and perhaps contribute back the code ?
Hello Again,
panel.add(textfield,new FormData(100, -1)); // 100px wide
That method changes the input box width not the label /:)
Well, I am pretty sure I will be contributing something soon to the code,
I just started using gxt yesterday...and I love it :D
Yours alawi,
gslender
1 Sep 2008, 9:49 PM
sorry...
http://extjs.com/deploy/gxtdocs/com/extjs/gxt/ui/client/widget/layout/FormLayout.html#setLabelWidth(int) sets the layout width for all labels in a formlayout
Oh yeah! That works, I knew I was not seeing it.
Thanks alot gslender! :D
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.