Displaying table column value as a combination of two or more entity attributes

I am looking for some help on displaying a column value as a combination of two or more Entity attributes.

For example: I have an entity named “Contact” with attributes “firstName”, “middleName” & “lastName”. How can I display the concatenation of values of these attributes under a column named “Name” in a simple table using CUBA framework?

Note: I am using CUBA Platform: 6.7.9

1 Like

hi Jasvir,

generally your question is answered here:

In case you want to do filtering through the generic filter mechanism, you have to persist the column. That can be easily achieved via entity listeners.

Bye
Mario

Hi Jasvir,

The easiest way would be to add a generated column:

  1. DataGrid: DataGrid - CUBA Platform. Developer’s Manual
  2. Table: Table - CUBA Platform. Developer’s Manual

For example:

    contactsTable.addGeneratedColumn("combo", entity -> {
        TextField field = componentsFactory.createComponent(TextField.class);
        Contact contact = (Contact) contactsTable.getItemDatasource(entity).getItem();
        field.setValue(contact.getFirstName() + " " + contact.getMiddleName() + " " + contact.getLastName());
        return field;
    });
1 Like

Thanks Olga.

I could achieve this using @MetaProperty in my entity class.

1 Like