Dinamically generated inline Button in table row

I am trying to programmatically add inline buttons in a table (or data grid).
The button should trigger an action which should have access to the entity represented on the table row, even if other row(s) in the table are selected.
Is there a clean way to achieve this (some way to link the generated button and the entity)?
I could not find an example of such functionality in samples, documentation, or forums.
Thak you very much in advance.



I managed to fullfull most of the requirement with the following strategy:

public class UserBrowse extends AbstractLookup {

    private Table<User> usersTable;

    private ComponentsFactory componentsFactory;

    private MyService myService;

    public void init(Map<String, Object> params) {

        usersTable.addGeneratedColumn("buttonColumn", user -> {
            Button button = componentsFactory.createComponent(Button.class);
            button.setCaption("do stuff");
            button.setAction(new BaseAction("stuff") {
                public void actionPerform(Component component) {
                    showNotification(myService.doStuff(user), NotificationType.HUMANIZED);
            return button;

The only tweak I’d like to make is to correct the line selection behaviour. Now, when I click on the button, the line is selected (or added to selection if CTRL is pressed).
Is there a way to force CUBA not to select the row on which the button is clicked?

Hi, Nicholas!

You’re doing in the right way. So, to prevent table’s row selection you can set the showSelection attribute to false.

1 Like

Oh! I missed that…
Thank you Gleb, very kind.

@nmckinno Hello, Nicholas, I stumbled across this while trying to do the exact same thing but I don’t know what package this should be in or what needs to be imported. I haven’t done any java at all in Cuba Platform, so far I have just been tweeking the xml views and doing a lot of googling.