LookupPickerField in table

I am using LookupPickerField in FieldGroup and Tables which optionsDatasource which is working nicely except one thing I am still exploring: how can I change the action option when it is used in a table.
Here is my code snipped from screen xml file.


<column id="glAccounts"
        editable="true" 
        optionsDatasource="glAccountsesDs" />
<column id="reference"

I was expecting if I case use something like action as below- but seems doesn’t work, not sure if it is supported yet. Thanks for any help.


<actions>
    <action id="lookup"/>
    <action id="open"/>
    <action id="clear"/>
</actions>

Hi,

the only way to achieve this is to use generated column for Table.

  1. Add new collection datasource for options of LookupPickerField:

<collectionDatasource id="usersDs"
                      class="com.haulmont.cuba.security.entity.User"
                      view="_minimal">
    <query>
        <![CDATA[select u from sec$User u]]>
    </query>
</collectionDatasource>
  1. Do not set editable=true for target column:

<table id="clientsTable"
       width="100%" editable="true">
    <actions>
        <action id="create"/>
        <action id="edit"/>
        <action id="remove"/>
    </actions>
    <columns>
        <column id="title" editable="true"/>
        <column id="user"/>
        <column id="order" editable="true"/>
    </columns>
    <rows datasource="clientsDs"/>
    ...
</table>
  1. Add generated column from init method:

public class ClientBrowse extends AbstractLookup {
    @Inject
    private Table<Client> clientsTable;

    @Inject
    private ComponentsFactory componentsFactory;

    @Inject
    private CollectionDatasource<User, UUID> usersDs;

    @Override
    public void init(Map<String, Object> params) {
        super.init(params);

        clientsTable.addGeneratedColumn("user", client -> {
            LookupPickerField field = componentsFactory.createComponent(LookupPickerField.class);
            field.setWidth("100%");
            field.setOptionsDatasource(usersDs);
            field.setDatasource(clientsTable.getItemDatasource(client), "user");
            field.addLookupAction();
            field.addClearAction();
            return field;
        });
    }
}

Thank you so much. it worked very excellently.