-
Notifications
You must be signed in to change notification settings - Fork 11
Actions on rows
You can add a number of actions to be performed in a concrete row. For doing that you just need to provide an special column, in the row type. E.g.:
// in the row class
private ColumnActionGroup actions;
public ColumnActionGroup getActions() {
if (status != null && StatusType.DANGER.equals(status.getType())) {
return new ColumnActionGroup(
new ColumnAction[] {
new ColumnAction("unblockRow", "Unblock", null),
new ColumnAction("deleteRow", "Delete", null)
});
}
return new ColumnActionGroup(new ColumnAction[] {new ColumnAction("blockRow", "Block", null)});
}
This code result in something like this:
Please notice that in the example we are creating a getter as we want the options to be dynamic as they depend on the status column of that row, but it could also be simplified if the actions are always the same for each row. E.g.:
private ColumnActionGroup actions = new ColumnActionGroup(
new ColumnAction[] {
new ColumnAction("deleteRow", "Delete", null)
}
);
The first parameter in the ColumnAction
constructor is the name of the method in the class implementing the Crud
interface, while the second parameter is the caption for that action and the third onw is an icon name.. E.g. in the crud class we will have something like this:
public void unblockRow(LanguageRow row) {
repo.findById((String) row.getId()).setStatus(new Status(StatusType.SUCCESS, "Unblocked"));
}
public void blockRow(LanguageRow row) {
repo.findById((String) row.getId()).setStatus(new Status(StatusType.DANGER, "Blocked"));
}
public void deleteRow(LanguageRow row) {
repo.removeAll(List.of(row));
}
Please notice that you always receive the row as parameter in those methods.
- Home
- Disclaimer
- See it in action
- User manual (v3)
- UX and IA
- Internals
- Roadmap
- Javadoc
- SonarQube
- Other MDD frameworks
- Thanks