PopupButton with table action

Hello,
just found popupButton doesn’t work with table actions out of the box. I think it’s possible to set actions programmatically.


<table id="newEntitiesTable"
       width="100%">
    <actions>
        <action id="create"/>
        <action id="edit"/>
        <action id="remove"/>
    </actions>
    <columns>
    </columns>
    <rows datasource="newEntitiesDs"/>
    <rowsCount/>
    <buttonsPanel id="buttonsPanel"
                  alwaysVisible="true">
        <popupButton caption="Actions">
            <actions>
                <action id="newEntitiesTable.create" />
            </actions>
        </popupButton>
        <button id="createBtn"
                action="newEntitiesTable.create"/>
        <button id="editBtn"
                action="newEntitiesTable.edit"/>
        <button id="removeBtn"
                action="newEntitiesTable.remove"/>
    </buttonsPanel>
</table>

Hi,

It’s by design - PopupButton is itself ActionsHolder and can only define its own actions. Only ActionOwner like Buttonusing a single action can use actions defined in other components (ActionsHolder’s).

Could you kindly give a quick example of how to set it programmatically? (i.e. call Table action from PopupButton?)
Thank you!

Here it is:

public class CustomerBrowse extends AbstractLookup {

    @Inject
    private PopupButton actionsBtn;

    @Inject
    private GroupTable<Customer> customersTable;

    @Override
    public void init(Map<String, Object> params) {
        actionsBtn.addAction(customersTable.getAction("create"));
        actionsBtn.addAction(customersTable.getAction("edit"));
        actionsBtn.addAction(customersTable.getAction("remove"));
    }
}
1 Like

Thank you!