Reputation: 11
I want to remove click handler for action cell based upon some input from object. How can this be done?
Currently, my code looks like this:
public static Column<vTO, vTO>
createReissueButtonColumn(String columnName) {
ActionCell<VolunteerTO> reListCell = new ActionCell<VTO>("Reissue",
new ActionCell.Delegate<VTO>() {
@Override
public void execute(VTO object) {
// code to be executed
}
})
{
@Override
public void render(Cell.Context context,VTO value,SafeHtmlBuilder sb) {
if(null != value.getStatus() && !"".equalsIgnoreCase(value.getStatus())) {
super.render(context,value,sb);
}
}
};
Column<VTO, VTO> reListColumn = new Column<VTO, VTO>(reListCell) {
@Override
public VTO getValue(VTO object) {
return object;
}
};
reListColumn.setDataStoreName(columnName);
reListColumn.setSortable(false);
return reListColumn;
}
Upvotes: 0
Views: 85
Reputation: 41089
You can simply ignore the click (do nothing) based on your conditions.
EDIT: In your code, in the execute() method you can either do something, or don't do it - based on a particular condition.
Alternatively, you can cancel a click event on this column:
unitTable.addCellPreviewHandler(new Handler<Unit>() {
@Override
public void onCellPreview(CellPreviewEvent<Unit> event) {
if ("click".equals(event.getNativeEvent().getType())) {
if (event.getColumn() != myTable.getColumnIndex(reListColumn)) {
// Check some condition. If necessary:
event.setCanceled(true);
}
}
}
});
Upvotes: 1