return nattable;
}
private void addCustomSelectionBehaviour() {
nattable.addLayerListener(new ILayerListener() {
// Default selection behavior selects cells by default.
public void handleLayerEvent(ILayerEvent event) {
if (event instanceof CellSelectionEvent) {
CellSelectionEvent cellEvent = (CellSelectionEvent) event;
log("Selected cell: ["
+ cellEvent.getRowPosition()
+ ", "
+ cellEvent.getColumnPosition()
+ "], "
+ nattable.getDataValueByPosition(
cellEvent.getColumnPosition(),
cellEvent.getRowPosition()));
}
}
});
// Events are fired whenever selection occurs. These can be use to
// trigger
// external actions as required. Also you can use this data to pull out
// the backing data from the IRowDataProvider. Example:
// rowDataProvider.getRowObject(natTable.getRowIndexByPosition(selectedRowPosition));
nattable.addLayerListener(new ILayerListener() {
public void handleLayerEvent(ILayerEvent event) {
if (event instanceof RowSelectionEvent) {
RowSelectionEvent rowEvent = (RowSelectionEvent) event;
log("Selected Row: "
+ ObjectUtils.toString(rowEvent
.getRowPositionRanges()));
}
}
});
nattable.addLayerListener(new ILayerListener() {
public void handleLayerEvent(ILayerEvent event) {
if (event instanceof ColumnSelectionEvent) {
ColumnSelectionEvent columnEvent = (ColumnSelectionEvent) event;
log("Selected Column: "
+ columnEvent.getColumnPositionRanges());