Gwt 如何在DynamicForm中设置TextItem的宽度
如何在Gwt 如何在DynamicForm中设置TextItem的宽度,gwt,smartgwt,Gwt,Smartgwt,如何在DynamicForm中设置TextItem的宽度 import com.smartgwt.client.widgets.Window; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.TextItem; public class AgeModelWindow extends Window { public AgeModelWindow
DynamicForm
中设置TextItem
的宽度
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.TextItem;
public class AgeModelWindow extends Window {
public AgeModelWindow() {
TextItem textItem = new TextItem();
textItem.setWidth(50);
textItem.setLength(3);
textItem.setTitle("Age");
DynamicForm form = new DynamicForm();
form.setNumCols(2);
//form.setColWidths("*", "50");
form.setWidth100();
form.setItems(textItem);
this.setMargin(10);
this.setTitle("Enter your age");
this.addItem(form);
this.setWidth(200);
this.setHeight(100);
this.setLeft(100);
this.setTop(100);
this.draw();
}
}
方法TextItem#setWidth()
未按预期工作
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.TextItem;
public class AgeModelWindow extends Window {
public AgeModelWindow() {
TextItem textItem = new TextItem();
textItem.setWidth(50);
textItem.setLength(3);
textItem.setTitle("Age");
DynamicForm form = new DynamicForm();
form.setNumCols(2);
//form.setColWidths("*", "50");
form.setWidth100();
form.setItems(textItem);
this.setMargin(10);
this.setTitle("Enter your age");
this.addItem(form);
this.setWidth(200);
this.setHeight(100);
this.setLeft(100);
this.setTop(100);
this.draw();
}
}
我也尝试过DynamicForm#setColWidths()
,但仍然无法设置宽度
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.TextItem;
public class AgeModelWindow extends Window {
public AgeModelWindow() {
TextItem textItem = new TextItem();
textItem.setWidth(50);
textItem.setLength(3);
textItem.setTitle("Age");
DynamicForm form = new DynamicForm();
form.setNumCols(2);
//form.setColWidths("*", "50");
form.setWidth100();
form.setItems(textItem);
this.setMargin(10);
this.setTitle("Enter your age");
this.addItem(form);
this.setWidth(200);
this.setHeight(100);
this.setLeft(100);
this.setTop(100);
this.draw();
}
}
这是我的密码
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.TextItem;
public class AgeModelWindow extends Window {
public AgeModelWindow() {
TextItem textItem = new TextItem();
textItem.setWidth(50);
textItem.setLength(3);
textItem.setTitle("Age");
DynamicForm form = new DynamicForm();
form.setNumCols(2);
//form.setColWidths("*", "50");
form.setWidth100();
form.setItems(textItem);
this.setMargin(10);
this.setTitle("Enter your age");
this.addItem(form);
this.setWidth(200);
this.setHeight(100);
this.setLeft(100);
this.setTop(100);
this.draw();
}
}
我在textItem上使用css样式解决了这个问题。我不知道为什么它不能通过SmartGWT中的代码工作
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.TextItem;
public class AgeModelWindow extends Window {
public AgeModelWindow() {
TextItem textItem = new TextItem();
textItem.setWidth(50);
textItem.setLength(3);
textItem.setTitle("Age");
DynamicForm form = new DynamicForm();
form.setNumCols(2);
//form.setColWidths("*", "50");
form.setWidth100();
form.setItems(textItem);
this.setMargin(10);
this.setTitle("Enter your age");
this.addItem(form);
this.setWidth(200);
this.setHeight(100);
this.setLeft(100);
this.setTop(100);
this.draw();
}
}
代码:
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.TextItem;
public class AgeModelWindow extends Window {
public AgeModelWindow() {
TextItem textItem = new TextItem();
textItem.setWidth(50);
textItem.setLength(3);
textItem.setTitle("Age");
DynamicForm form = new DynamicForm();
form.setNumCols(2);
//form.setColWidths("*", "50");
form.setWidth100();
form.setItems(textItem);
this.setMargin(10);
this.setTitle("Enter your age");
this.addItem(form);
this.setWidth(200);
this.setHeight(100);
this.setLeft(100);
this.setTop(100);
this.draw();
}
}
textItem.setCellStyle("textItemAge");
.textItemAge input,.textItemAgeFocused input,.textItemAgeDisabled input,.textItemAgeDisabledHint input,.textItemAgeError input,.textItemAgeHint input
{
width: 50px !important;
}
css:
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.TextItem;
public class AgeModelWindow extends Window {
public AgeModelWindow() {
TextItem textItem = new TextItem();
textItem.setWidth(50);
textItem.setLength(3);
textItem.setTitle("Age");
DynamicForm form = new DynamicForm();
form.setNumCols(2);
//form.setColWidths("*", "50");
form.setWidth100();
form.setItems(textItem);
this.setMargin(10);
this.setTitle("Enter your age");
this.addItem(form);
this.setWidth(200);
this.setHeight(100);
this.setLeft(100);
this.setTop(100);
this.draw();
}
}
textItem.setCellStyle("textItemAge");
.textItemAge input,.textItemAgeFocused input,.textItemAgeDisabled input,.textItemAgeDisabledHint input,.textItemAgeError input,.textItemAgeHint input
{
width: 50px !important;
}
删除
form.setColWidths(“*”,“10”)代码>应该可以解决此问题。我正在使用SmartClient版本v9.0p_2013-09-22/PowerEdition部署(内置于2013-09-22)和GWT版本2.5。删除setColWidths后它不工作。textItem
的宽度是多少?默认情况下,textItem的宽度是200px。