GWT:如何获取cellTable的复选框的值 [英] GWT:how to get the value of a checkbox of a cellTable

查看:109
本文介绍了GWT:如何获取cellTable的复选框的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有这种情况下,我想删除这个celltable中的复选框是检查这个删除按钮clik上的对象,

任何想法如何获得这些对象的复选框在这个cellTable中检查,当我点击delte按钮时。



谢谢

解决方案

如果你的要求与删除单行,那么你可以使用SingleSelectionModel否则MulitiSelectionModel celltable中。我已经用单选模型编写了一些代码,它可能会提供一些想法。即

  selectionModel = new SingleSelectionModel< T>(); 
cellTable.setSelectionModel(selectionModel)//设置到你的cellTable中:

当你选择复选框,然后行将自动选择,对象将设置为选择模型。

  CheckboxCell checkboxCell = new CheckboxCell(true,false) ; 
Column< T,Boolean> boolColumn = new Column< T,Boolean>(
checkboxCell){
@Override
public Boolean getValue(T object){
return selectionModel.isSelected(object);
}
};

点击删除按钮,使用选中的对象,它会为您提供一个删除对象。
selectionModel.getSelectedObject();


I have this situation , i want to delete the objects in this celltable whose checkbox is Check on the clik of this "Delete" Button ,

Any idea how to get those objects whose checkbox is checked in this cellTable, when i click the delte button ..

Thanks

解决方案

If your requirement with delete single row, then You can use SingleSelectionModel otherwise MulitiSelectionModel in celltable. I have written some code with single selection model,It may give some idea. i.e.

selectionModel = new SingleSelectionModel<T>();
cellTable.setSelectionModel(selectionModel) //Set into your cellTable:

When you select a checkbox, then row will auto selected and object will set in to selection model.

  CheckboxCell checkboxCell=new CheckboxCell(true, false); 
            Column<T, Boolean> boolColumn=new Column<T, Boolean>(
                        checkboxCell) {
            @Override
            public Boolean getValue(T object) {                            
             return selectionModel.isSelected(object); 
        }
        };

On delete button click,use selected object,It will provide you a object for delete. selectionModel.getSelectedObject();

这篇关于GWT:如何获取cellTable的复选框的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆