-
18 Dec 2011 10:18 PM #1
Set label size for formpanel widgets
Set label size for formpanel widgets
Hi,
In Ext-Gwt 2 one was able to set the label size of widgets by calling setLabelSize(..) method on the formPanel. In Ext-Gwt 3 this method is gone. I see there is a FieldLabel widget but the setFieldLabel method has no effect. Any help
-
19 Dec 2011 2:10 AM #2
As far as I understand the correct usage of FieldLabel in v3 is:
Code:TextField field = new TextField(); FieldLabel label = new FieldLabel(field, "Your label"); // Attach only label to a container, field will be attached automatically. All the labels and fields will be resized to the same size automatically, you have to size only the outer container.
-
19 Dec 2011 2:46 AM #3
Thanks for the reply. However the problem I have is how to specify the label width. When I look at the source code for FieldLabel it seems that by calling setWidth we can specify the percentage width for our fieldLabel widget where the fieldLabel consist of labelText and a textField widget. The labelWidth defaults to 100 according the javaDocs which results in my longer labels displays in two lines.
untitled.png
//My code
TextField txtRegistrationNr = new TextField();
FieldLabel fieldLabel = new FieldLabel( txtRegistrationNr, labelText);
fieldLabel.setWidth("80%");
fieldLabel.setLabelWidth(150);
I can't see that the value specified for labelWidth is ever used in FieldLabel source code.
Hope I made myself more clear.
Any ideas?
-
19 Dec 2011 3:50 AM #4
By calling method setWidth("80%") you specify FieldLabel width to 80% of the outer container (that is, field label including the Field widget, as they are combined as one).
There is inner interface in FieldLabel class called FieldLabelAppearance that is responsible for rendering the widget, so there is no wonder you can't see labelWidth used in FieldLabel class.
But I can only confirm, that I can't get your caption (Regstration Number) in one line as well. I guess there has to be bug in FielLabelAppearance, because label's width is always 100px in firebug no matter what size i've set.
I can olny suggest you to use shorter label and use tooltip until it's been fixed. Or you can set label to be placed on the top of the field:
Code:label.setLabelAlign(LabelAlign.TOP);
-
17 Jan 2012 11:27 AM #5
Here is a workaround to adjust FieldLabel width:
The problem is that label is rendered to html in constructor, before one can set label width and affect the render process.Code:FieldLabel fieldLabel = new FieldLabel(field, "Your very long label title here", new FieldLabelDefaultAppearance() { @Override public void render(SafeHtmlBuilder sb, String id, FieldLabel label) { label.setLabelWidth(150); super.render(sb, id, label); } });
-
17 Jan 2012 11:03 PM #6
-
18 Jan 2012 11:46 AM #7
Would be great if someone from Ext GWT fix it.
Actually, there should be a way either to set size using the longest label on the same form or introduce smart label wrapping (on two or more lines) respecting the set label width.
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote