use of org.dominokit.domino.ui.datatable.RowCell in project domino-ui-demo by DominoKit.
the class DataTableViewImpl method treeGridFullParentSpan.
@SampleMethod
private void treeGridFullParentSpan() {
TableConfig<Contact> tableConfig = new TableConfig<>();
tableConfig.addColumn(ColumnConfig.<Contact>create("id", "#").textAlign("right").asHeader().setCellRenderer(cell -> TextNode.of(cell.getTableRow().getRecord().getIndex() + 1 + ""))).addColumn(ColumnConfig.<Contact>create("status", "Status").textAlign("center").setCellRenderer(cell -> {
if (cell.getTableRow().getRecord().isActive()) {
return Style.of(Icons.ALL.check_circle()).setColor(Color.GREEN_DARKEN_3.getHex()).element();
} else {
return Style.of(Icons.ALL.highlight_off()).setColor(Color.RED_DARKEN_3.getHex()).element();
}
})).addColumn(ColumnConfig.<Contact>create("gender", "Gender").setCellRenderer(cell -> ContactUiUtils.getGenderElement(cell.getRecord())).textAlign("center")).addColumn(ColumnConfig.<Contact>create("eyeColor", "Eye color").setCellRenderer(cell -> ContactUiUtils.getEyeColorElement(cell.getRecord())).textAlign("center")).addColumn(ColumnConfig.<Contact>create("balance", "Balance").setCellRenderer(cellInfo -> ContactUiUtils.getBalanceElement(cellInfo.getRecord()))).addColumn(ColumnConfig.<Contact>create("email", "Email").setCellRenderer(cell -> TextNode.of(cell.getTableRow().getRecord().getEmail()))).addColumn(ColumnConfig.<Contact>create("phone", "Phone").setCellRenderer(cell -> TextNode.of(cell.getTableRow().getRecord().getPhone()))).addColumn(ColumnConfig.<Contact>create("badges", "Badges").setCellRenderer(cell -> {
if (cell.getTableRow().getRecord().getAge() < 35) {
return Badge.create("Young").setBackground(ColorScheme.GREEN.color()).element();
}
return TextNode.of("");
})).onUtilityColumn(utilityColumn -> {
utilityColumn.setTitle("First name").setSortable(true, "id");
}).setMultiSelect(true).addPlugin(new SortPlugin<>()).addPlugin(new SelectionPlugin<>()).addPlugin(new RecordDetailsPlugin<>(cell -> new ContactDetails(cell).element())).addPlugin(new RowMarkerPlugin<>(tableCellInfo -> ContactUiUtils.getBalanceColor(tableCellInfo.getRecord()))).addPlugin(new TreeGridPlugin<Contact>((parent, itemsConsumer) -> {
itemsConsumer.accept(Optional.ofNullable(parent.getFriends()));
}).setIndentColumnElementSupplier(tableRow -> Paragraph.create(tableRow.getRecord().getName()).setMarginBottom("0").element()).setParentRowCellsSupplier((dataTable, tableRow) -> {
HTMLTableCellElement cellElement = DominoElement.of(td()).setAttribute("colspan", "8").element();
RowCell<Contact> rowCell = new RowCell<>(new CellRenderer.CellInfo<>(tableRow, cellElement), dataTable.getTableConfig().getColumnByName("id"));
return Collections.singletonList(rowCell);
}).setIndent(60));
LocalListDataStore<Contact> localListDataStore = new LocalListDataStore<>();
DataTable<Contact> table = new DataTable<>(tableConfig, localListDataStore);
element.appendChild(Card.create("TREE GRID PLUGIN - Full PARENT SPAN", "Render records in tree style with expand and collapse features").setCollapsible().appendChild(new TableStyleActions(table)).appendChild(table).element());
contactListParseHandlers.add(contacts -> {
localListDataStore.setData(contacts.subList(0, 25));
table.load();
});
}
Aggregations