问题描述
我有这种情况下,我想删除这个celltable中的复选框是检查这个删除按钮clik上的对象,
任何想法如何获得这些对象的复选框在这个cellTable中检查,当我点击delte按钮时。
谢谢
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的复选框的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!