Hi guys,
I am trying to add a Column using TextInputCell into a CellTable. The code
is like below:
//the display data class:
public class Foo {
...
//the field to be used in CellTable
int quantity;
...
//setters and getters...
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
...
}
//In the entry point onModuleLoad():
CellTable<Foo> cellTable = new CellTable<Foo>();
final ListDataProvider<Foo> dataProvider = new ListDataProvider<Foo>();
Column<Foo, String> quantityCol = new Column<Foo, String>(cell) {
@Override
public String getValue(Foo object) {
//format the integer with MyFormatter to add thousand separators.
//e.g. 1000 -> 1,000
return MyFormatter.*addSeparator*(object.getQuantity());
}
};
quantityCol.setFieldUpdater(new FieldUpdater<Foo, String>() {
@Override
public void update(int index, Foo object, String value) {
// remove thousand seperator, e.g. 1,000 -> 1000
// and set it back to the object.
object.setQuantity(MyFormatter.*removeSeparator*(value));
//to refresh the display.
dataProvider.refresh();
}
});
//add this column to cellTable
cellTable.addColumn(quantityCol, "Quantity");
//adds cellTable to the dataProvider.
dataProvider.addDataDisplay(cellTable);
//adds it to the RootPanel.
RootPanel.get().add(cellTable);
//creates a data object, and push it into dataProvider to display.
Foo foo = new Foo();
foo.setQuantity(1000);
dataProvider.getList().add(foo);
*Problem*:
The cellTable correctly shows a formatted value 1,000 in the TextInputCell
after the page finished its loading.
After I input a value, e.g. 100000. the TextInputCell remained its display
100000, rather than displaying a formatted value 100,000.
I have debugged that getValue(Foo object) did get invoked after
dataProvider.refresh(), and its return value is as correct as 100,000.
I have tried using cellTable.redraw() instead of dataProvider.refresh(). It
does not work either.
The GWT version I am using is 2.5.0 release.
Does anyone know why the TextInputCell never gets updated accordingly after
Column.getValue(T object), or whether this is the right solution to use
cases like above?
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.