org.dominokit.domino.ui.datatable.plugins.RowClickPlugin Maven / Gradle / Ivy
package org.dominokit.domino.ui.datatable.plugins;
import org.dominokit.domino.ui.datatable.DataTable;
import org.dominokit.domino.ui.datatable.TableRow;
import org.dominokit.domino.ui.utils.DominoElement;
import org.jboss.elemento.EventType;
public class RowClickPlugin implements DataTablePlugin {
private ClickHandler handler;
public RowClickPlugin(ClickHandler handler) {
this.handler = handler;
}
@Override
public void onRowAdded(DataTable dataTable, TableRow tableRow) {
DominoElement.of(tableRow.element()).styler(style -> style.setCursor("pointer"));
tableRow.element().addEventListener(EventType.click.getName(), evt -> handler.onClick(tableRow));
}
@FunctionalInterface
public interface ClickHandler {
void onClick(TableRow tableRow);
}
}