use of io.jmix.ui.component.data.table.ContainerTableItems in project jmix-docs by Haulmont.
the class TableScreen method onInit.
// end::inject-tableClick[]
// tag::onInit-start[]
@Subscribe
public void onInit(InitEvent event) {
// end::onInit-start[]
customersTable.addGeneratedColumn("aaa", entity -> null);
// tag::add-base-action[]
customersTable.addAction(new AboutSingleAction());
// end::add-base-action[]
// tag::add-ItemTrackingAction[]
customersTable.addAction(new ItemTrackingAction("about") {
@Nullable
@Override
public String getCaption() {
return "About";
}
@Override
public void actionPerform(Component component) {
notifications.create().withCaption("Hello " + customersTable.getSelected().iterator().next()).withType(Notifications.NotificationType.TRAY).show();
}
});
// end::add-ItemTrackingAction[]
// tag::table-set-style-name[]
tableBorderless.setStyleName(ThemeClassNames.TABLE_BORDERLESS);
// end::table-set-style-name[]
// tag::column-value-provider[]
printableTableExcelExport.addColumnValueProvider("firstName", context -> {
// <1>
Customer customer = context.getEntity();
return "Name: " + customer.getFirstName();
});
// end::column-value-provider[]
printableTableExcelExport.addColumnValueProvider("fullName", context -> {
Customer customer = context.getEntity();
return customer.getFirstName() + " " + customer.getLastName();
});
// tag::table-add-printable[]
/*printableTable.addPrintable("firstName", new Table.Printable<Customer, String>() {
@Override
public String getValue(Customer item) {
return "Name: " + item.getFirstName();
}
});*/
// end::table-add-printable[]
// tag::printable-column-generator[]
/*printableTable.addGeneratedColumn("fullName", new Table.PrintableColumnGenerator<Customer, String>() {
@Override
public String getValue(Customer item) {
return item.getFirstName() + " " + item.getLastName();
}
@Override
public Component generateCell(Customer entity) {
Label label = uiComponents.create(Label.NAME);
label.setValue(entity.getFirstName() + " " + entity.getLastName());
return label;
}
});*/
// end::printable-column-generator[]
// tag::item-click-action[]
tableClick.setItemClickAction(new BaseAction("itemClickAction").withHandler(actionPerformedEvent -> {
Customer customer = tableClick.getSingleSelected();
if (customer != null) {
notifications.create().withCaption("Item clicked for: " + customer.getFirstName() + "" + customer.getLastName()).show();
}
}));
// end::item-click-action[]
// tag::enter-press-action[]
tableClick.setEnterPressAction(new BaseAction("enterPressAction").withHandler(actionPerformedEvent -> {
Customer customer = tableClick.getSingleSelected();
if (customer != null) {
notifications.create().withCaption("Enter pressed for: " + customer.getFirstName() + "" + customer.getLastName()).show();
}
}));
// end::enter-press-action[]
// tag::programmatic-binding[]
customersTable1.setItems(new ContainerTableItems<>(customersDc));
// end::programmatic-binding[]
// tag::onInit-end[]
}
use of io.jmix.ui.component.data.table.ContainerTableItems in project jmix by jmix-framework.
the class InspectorTableBuilder method build.
public Table build() {
Table table = uiComponents.create(Table.NAME);
// collect properties in order to add non-system columns first
List<MetaProperty> nonSystemProperties = new ArrayList<>(10);
List<MetaProperty> systemProperties = new ArrayList<>(10);
for (MetaProperty metaProperty : metaClass.getProperties()) {
// don't show embedded, transient & multiple referred entities
if (isEmbedded(metaProperty) || !metadataTools.isJpa(metaProperty)) {
continue;
}
if (isMany(metaProperty)) {
continue;
}
if (metadataTools.isAnnotationPresent(metaClass.getJavaClass(), metaProperty.getName(), Convert.class)) {
continue;
}
if (!metadataTools.isSystem(metaProperty)) {
nonSystemProperties.add(metaProperty);
} else if (withSystem) {
systemProperties.add(metaProperty);
}
}
for (MetaProperty metaProperty : nonSystemProperties) {
addMetaPropertyToTable(table, metaProperty);
}
for (MetaProperty metaProperty : systemProperties) {
addMetaPropertyToTable(table, metaProperty);
}
table.setSizeFull();
if (buttonsPanelInitializer != null) {
table.setButtonsPanel(uiComponents.create(ButtonsPanel.class));
buttonsPanelInitializer.accept(table);
}
SimplePagination simplePagination = uiComponents.create(SimplePagination.NAME);
table.setPagination(simplePagination);
table.setItems(new ContainerTableItems(collectionContainer));
if (table.getAction(EditAction.ID) != null) {
table.setEnterPressAction(table.getAction(EditAction.ID));
table.setItemClickAction(table.getAction(EditAction.ID));
}
table.setMultiSelect(withMultiselect);
table.addStyleName("table-boolean-text");
return table;
}
Aggregations