I am trying to insert a textbox inside a datagrid column. I know I could have gone with TextCell or EditTextCell but for some reason I went with TextBox.
I went with the following approach
Cell<String> cell = new AbstractCell<String>()
{
@Override
public void render( com.google.gwt.cell.client.Cell.Context context, String value, SafeHtmlBuilder sb )
{
FlowPanel fp = new FlowPanel();
TextBox tb = new TextBox();
tb.setText( value );
fp.add( tb );
sb.appendEscaped( fp.getElement().getString() );
}
};
// Address.
Column<ContactInfo, String> addressColumn = new Column<ContactInfo, String>( cell )
{
@Override
public String getValue( ContactInfo object )
{
return object.getAddress();
}
};
The problem I encountered here is that I am getting the following in the UI instead of textbox
<div><input class="gwt-TextBox" type="text"></div>
But when I replaced
sb.appendEscaped( fp.getElement().getString() );
with
sb.appendHtmlConstant( fp.getElement().getInnerHTML() );
I am getting the textbox, But the value is not populating.
Can anyone explain this behaviour. How can I populate the value?