Hello,
I've been trying to resolve this problem for quite some time now, with no results.
We've got a ListGrid with 5 fields. We've got a RecordClickHandler in the ListGrid which opens a new tab when a row is clicked.
What we would want to do is exclude/override the handler in one column. That column is a custom made MyRemoveListGridField, which extends ListGridField, and has custom logic for record removal implemented with a RecordClickHandler.
I read the documentation:
... but I can't really understand what the last sentence means. Where am I supposed to return false? Has someone got a working sample code?
Using version: SC_SNAPSHOT-2011-05-05/EVAL
Custom ListGridField constructor:
Thanks in advance.
I've been trying to resolve this problem for quite some time now, with no results.
We've got a ListGrid with 5 fields. We've got a RecordClickHandler in the ListGrid which opens a new tab when a row is clicked.
What we would want to do is exclude/override the handler in one column. That column is a custom made MyRemoveListGridField, which extends ListGridField, and has custom logic for record removal implemented with a RecordClickHandler.
I read the documentation:
HandlerRegistration addRecordClickHandler(RecordClickHandler handler)
Executed when this field is clicked on. Note that if ListGrid.recordClick is also defined, it will be fired for fields that define a recordClick handler if the field-level handler returns true. Return false to prevent the grid-level handler from firing.
Executed when this field is clicked on. Note that if ListGrid.recordClick is also defined, it will be fired for fields that define a recordClick handler if the field-level handler returns true. Return false to prevent the grid-level handler from firing.
Using version: SC_SNAPSHOT-2011-05-05/EVAL
Custom ListGridField constructor:
Code:
public MyRemoveListGridField(final ListGrid list, String name, String title, final String confirmQuestion,
final DSCallback callback) {
super(name);
setTitle(title);
setType(ListGridFieldType.ICON);
setWidth(16 + 6); // icon = 16x16
setCellIcon("/edoctoral/images/remove.png");
addRecordClickHandler(new RecordClickHandler() {
@Override
public void onRecordClick(final RecordClickEvent event) {
SC.confirm(Texts.get("removeQuestion"), confirmQuestion, new BooleanCallback() {
public void execute(Boolean value) {
if (Boolean.TRUE.equals(value)) {
if (callback != null) {
list.removeData(event.getRecord(), callback);
} else {
list.removeData(event.getRecord());
}
}
}
});
}
});
}
Code:
ListGrid myList = new ListGrid();
ListGridField id = new ListGridField("id");
ListGridField oid = new ListGridField("oid");
ListGridField type = new ListGridField("type");
ListGridField name = new ListGridField("name");
ListGridField remove = new MyRemoveListGridField(myList, "remove", "", Texts.get("confirmRemoveDocument"));
myList.addRecordClickHandler(getRecordClickhandler()); // <-- this should be overriden in MyRemoveListGridField.
myList.setFields(id, oid, type, name, remove);
Comment