Gwt TextInputCell不显示更改的值 [英] Gwt TextInputCell doesn't show changed value
问题描述
我有一列TextInputCells的CellTable。
当我通过UI设置值时,手动修改bean。
但是,当我将值直接设置到bean中时,我无法让表格显示修改。它会一直保留我手动分配的东西。
这是我的专栏:
FieldUpdater< MyBean,String> myFu = new FieldUpdater< MyBean,String>(){
@Override
public void update(int index,MyBean object,String value){
object.setValue(value);
}
};
Column< MyBean,String> myCol = new Column< MyBean,String>(new TextInputCell()){
@Override
public String getValue(MyBean object){
return object.getValue();
}
};
以下是操作:
@UiHandler(myButton)
public void myButton_onClick(ClickEvent event){
for(MyBean my:listOfBeans)
my.setValue(value);
我尝试调用 table.redraw()
或清除并重新填充 ListDataProvider
,但它不会改变任何内容。
我可以做什么?
谢谢
好的,我发现了一个(牵强的)方式。它是蹩脚的,但它的工作。
int inputTextColumnPos; //你的列的位置
...
@UiHandler(myButton)
public void myButton_onClick(ClickEvent event){
for MyBean my:listOfBeans){
my.setValue(value);
//获取要更新的单元格
TextInputCell cell =(TextInputCell)table.getColumn(inputTextColumnPos).getCell();
//为单元格重新创建视图数据,因为当前没有更新
TextInputCell.ViewData viewData = new TextInputCell.ViewData(value);
// CRUSH另一个
cell.setViewData(my,viewData);
}
//因为我们从不太确定
table.redraw();
}
I have a CellTable with a column of TextInputCells.
When i set the value through the UI, manually, the bean is modified. But, then, when i set the value directly into the bean, i can't make the Table to show the modification. It will always keep what i assigned manually.
Here's my column :
FieldUpdater<MyBean, String> myFu = new FieldUpdater<MyBean, String>() {
@Override
public void update(int index, MyBean object, String value) {
object.setValue(value);
}
};
Column<MyBean, String> myCol = new Column<MyBean, String>(new TextInputCell()) {
@Override
public String getValue(MyBean object) {
return object.getValue();
}
};
Here's the action :
@UiHandler("myButton")
public void myButton_onClick(ClickEvent event) {
for (MyBean my : listOfBeans)
my.setValue("value");
}
I tried to call table.redraw()
or clearing and refilling the ListDataProvider
, after the action, but it doesn't change anything.
What can i do ?
Thanks
Ok, i found a (far fetched) way. It's crappy but it works.
int inputTextColumnPos; // position of your column
...
@UiHandler("myButton")
public void myButton_onClick(ClickEvent event) {
for (MyBean my : listOfBeans) {
my.setValue("value");
// get the cell you want to update
TextInputCell cell = (TextInputCell) table.getColumn(inputTextColumnPos).getCell();
// re-create the view data for the cell because the current one isn't updated
TextInputCell.ViewData viewData = new TextInputCell.ViewData("value");
// CRUSH the other one
cell.setViewData(my, viewData);
}
// because we're never too sure
table.redraw();
}
这篇关于Gwt TextInputCell不显示更改的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!