Lookup type in Jmix + Datagrid

Hi

With CUBA Platform, you could define lookup type as a dropdown for an entity attribute and then it would enable you to use a dropdown instead of a lookup screen in an editable DataGrid. Is there a similar thing available in Jmix already built in or am I missing something?

I’m asking this as the property is not available in the data model designer as it was previously in Cuba.

Thanks.

–Jonni

Hi.
You should use EntityComboBox instead of LookupField.
For example:

    @Autowired
    private DataGrid<User> usersTableGrid;
    @Autowired
    private UiComponents uiComponents;
  
    @Autowired
    private CollectionContainer<NewEntity> newEntitiesDc;

    @Subscribe
    protected void onInit(InitEvent event) {
           usersTableGrid.getColumnNN("newentity").setEditFieldGenerator(userEditor -> {
            EntityComboBox<NewEntity> entityComboBox = uiComponents.create(EntityComboBox.NAME);

            entityComboBox.setValueSource((ValueSource<NewEntity>) userEditor
                    .getValueSourceProvider().getValueSource("newentity"));
            entityComboBox.setOptionsContainer(newEntitiesDc);
            return entityComboBox;
        });
    }

More information about EntityComboBox

Regards,
Nadezhda

There is also a declarative way of defining what component to use for selecting an entity in generic mechanisms. It is based on the jmix.ui.entityFieldType and jmix.ui.entityFieldActions properties.

Try to add the following lines to your application.properties:

# component to select app_MyEntity (should implement EntityPicker)
jmix.ui.entityFieldType.app_MyEntity = entityComboBox

# what actions to add to the app_MyEntity selection component
jmix.ui.entityFieldActions.app_MyEntity = entity_lookup, entity_open, entity_clear

Regards,
Konstantin