点击删除字段按钮有没有办法让用户弹出提示窗口?
启用删除按钮:
setCanRemoveRecords(true);
当我点击红色删除按钮时,我想要一个确认框询问我是否要删除它,是或否。我该怎么用才能搞清楚?
我应该在
中添加内容吗? @Override
public void removeData(Record group)
{
...
}
答案 0 :(得分:1)
您可以使用以下方法:
ListGrid#setWarnOnRemoval
用于显示警告消息和
ListGrid#setWarnOnRemovalMessage
用于设置自定义消息。
答案 1 :(得分:1)
以下是选项:
addCellClickHandler
上使用ListGrid
并根据单元格号addRecordClickHandler
本身上添加ListGridField
我更喜欢上一个选项。
示例代码:
final ListGrid countryGrid = new ListGrid();
...
countryGrid.setWarnOnRemoval(true);
countryGrid.setCanRemoveRecords(true);
ListGridField ls = new ListGridField();
countryGrid.setRemoveFieldProperties(ls);
ls.setHoverCustomizer(new HoverCustomizer() {
@Override
public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
// System.out.println(colNum);
return "click here to delete this record";
}
});
ls.addRecordClickHandler(new RecordClickHandler() {
@Override
public void onRecordClick(final RecordClickEvent event) {
SC.confirm("Are you sure?", new BooleanCallback() {
@Override
public void execute(Boolean value) {
if (value == null || !value) {
event.cancel();
}
}
});
}
});
/*countryGrid.addCellClickHandler(new CellClickHandler() {
@Override
public void onCellClick(final CellClickEvent event) {
// column number having delete icon
// System.out.println(event.getColNum());
if (event.getColNum() == 3) {
SC.confirm("Are you sure", new BooleanCallback() {
@Override
public void execute(Boolean value) {
if (value == null || !value) {
event.cancel();
}
}
});
}
}
});*/