PDA

View Full Version : Form field width



itpragmatik
8 Dec 2009, 10:05 PM
How do I control the field width in a form? Most of the form examples under Ext GWT Explorer Demo show all form fields with same width. What if I want certain field shorter/longer than others? field.setWidth() is what I assumed, I tried that but that doesn't seem to do the trick? What am I doing wrong? The fields are part of a FormPanel and this form panel is nested in a ContentPanel.

Thanks.

marman
9 Dec 2009, 4:50 AM
FormPanel has a setFieldWidth method on it

itpragmatik
9 Dec 2009, 8:46 AM
FormPanel's setFieldWidth will set width for all the fields in a form. Correct? That's not what I am looking for. I want to set different display width for each field - not same for all the fields.

TheBuzzer
9 Dec 2009, 11:51 AM
do something like

mylayout.add(widget, new FormData(widgetwidth,-1));

itpragmatik
9 Dec 2009, 6:51 PM
This is how the code looks like which is not doing what I wanted it to do. What else can I try?

Thanks.


FormData formData = new FormData("-20");
FormPanel form2 = new FormPanel();
form2.setId("searchForm");

form2.setFrame(true);
form2.setHeaderVisible(true);
form2.setHeading("Search Users");
form2.setLayout(new FlowLayout());

FormLayout layout = new FormLayout();
layout.setLabelWidth(75);
layout.setLabelAlign(LabelAlign.RIGHT);
form2.setLayout(layout);

TextField<String> firstName = new TextField<String>();
firstName.setFieldLabel("First Name");
firstName.setWidth(75);
form2.add(firstName, formData);

TextField<String> lastName = new TextField<String>();
lastName.setFieldLabel("Last Name");
lastName.setWidth(75);
form2.add(lastName, formData);

TheBuzzer
9 Dec 2009, 7:20 PM
try



FormPanel form2 = new FormPanel();
form2.setId("searchForm");

form2.setFrame(true);
form2.setHeaderVisible(true);
form2.setHeading("Search Users");
form2.setLayout(new FlowLayout());

FormLayout layout = new FormLayout();
layout.setLabelWidth(75);
layout.setLabelAlign(LabelAlign.RIGHT);
form2.setLayout(layout);

TextField<String> firstName = new TextField<String>();
firstName.setFieldLabel("First Name");
form2.add(firstName, new FormData(75,-1));

TextField<String> lastName = new TextField<String>();
lastName.setFieldLabel("Last Name");
form2.add(lastName, new FormData(75,-1));[/QUOTE]

itpragmatik
9 Dec 2009, 8:38 PM
It worked. Thanks for your help.