我有一个相当奇特的问题。我正在使用 GWT 2.2 版本的 CellTable。CellTable 配置为固定布局。我在表中有一个可编辑的列(TextInputCell)。
我目前在 CellTabel 上使用 setColumnWidth 方法来固定列的宽度。这很好用,但它不会对输入文本元素实施宽度约束。结果,编辑器输入字段在列下溢出,给人一种被剪掉的印象。
这是一个来自 GWT 文档的代码示例,经过修改以演示该问题。请注意,名称字段未调整大小并在表内溢出。
public class Trial 实现 EntryPoint { private static class Contact { private static int nextId = 0;
private final int id;
private final String address;
private Date birthday;
private String name;
private Long number;
public Contact( String name, Date birthday, String address, Long number )
{
nextId++;
this.id = nextId;
this.name = name;
this.birthday = birthday;
this.address = address;
this.number = number;
}
}
private static final List<Contact> CONTACTS = Arrays.asList( new Contact( "John", new Date( 80, 4, 12 ), "123 Fourth Avenue", 0L ), new Contact( "Joe",
new Date( 85, 2, 22 ), "22 Lance Ln", 1L ), new Contact( "George", new Date( 46, 6, 6 ), "1600 Pennsylvania Avenue", 2L ) );
public void onModuleLoad( )
{
final CellTable<Contact> table = new CellTable<Contact>( 10 );
table.setWidth( "60px", true );
ListDataProvider<Contact> listPrvdr;
final TextInputCell nameCell = new TextInputCell( );
Column<Contact, String> nameColumn = new Column<Contact, String>( nameCell )
{
@Override
public String getValue( Contact object )
{
return object.name;
}
};
table.addColumn( nameColumn, "Name" );
table.setColumnWidth( nameColumn, "60px" );
nameColumn.setFieldUpdater( new FieldUpdater<Contact, String>( )
{
public void update( int index, Contact object, String value )
{
object.name = value;
table.redraw( );
}
} );
listPrvdr = new ListDataProvider<Contact>( );
listPrvdr.addDataDisplay( table );
RootPanel.get( ).add( table );
listPrvdr.getList( ).addAll( CONTACTS );
}
}
我错过了什么?如何对输入字段而不只是主机列强制执行宽度约束?