Strange behavior on datagrid

Hello!
I have a transient entity , showed by a datagrid, which can be added, edited and deleted by
an input dialog.
Adding and deleting is ok.
To edit the user double clicks on an entry and it will be opened via the input dialog.
The unexpected thing is: the selected (and opened) row is always the last one, no matter which
entry is selected. I’ve tried several approaches for days but the result is always the same.
Any help is appreciated.
There are three relevant events:

@Subscribe("dgSplitPages")
public void onDgPagesSelection(DataGrid.SelectionEvent<SplitPages> event) {
    if(event.isUserOriginated()){
        SplitPages splitPages = dgSplitPages.getSingleSelected();
        editSplitPages(splitPages);
    }
}

@Subscribe("addSplit")
public void onAddSplitClick(Button.ClickEvent event) {
    editSplitPages(null);
    delSplit.setEnabled(true);
}

@Subscribe("delSplit")
public void onDelSplitClick(Button.ClickEvent event) {
    if(dgSplitPages.getSelected().size() > 0){
        splitPagesDc.getMutableItems().remove(dgSplitPages.getSingleSelected());
    }
    if(splitPagesDc.getMutableItems().size() == 0){
        dgSplitPages.setVisible(false);
        btnSplitDocument.setEnabled(false);
        delSplit.setEnabled(false);
    }
}

And the XML:

                    <dataGrid id="dgSplitPages" dataContainer="splitPagesDc" width="100%" stylename="no-stripes no-vertical-lines no-horizontal-lines"
                              columnsCollapsingAllowed="false" reorderingAllowed="false" settingsEnabled="false">
                        <columns>
                            <column id="page" caption="mainMsg://captSeite" width="50" property="page" sortable="false" resizable="false"/>
                            <column id="docKategorie" caption="mainMsg://captKategorie" width="150" property="docKategorie" sortable="false" resizable="false"/>
                        </columns>
                    </dataGr

Hi,

DataGrid.SelectionEvent handle selection changes, not double clicks. I’d recommend using DataGrid.ItemClickEvent instead, e.g.:

@Subscribe("personsTable")
public void onPersonsTableItemClick(DataGrid.ItemClickEvent<Person> event) {
    if (event.isDoubleClick()) {
        Person item = event.getItem();
        notifications.create()
                .withCaption("Clicked: " + item.getName())
                .withType(Notifications.NotificationType.TRAY)
                .show();
    }
}

Regards,
Gleb

Thanks Gleb!
But before the posting I tried all available events, and this one ends up, also this one, in the result as described.
Is there anything wrong with the dataContainer?

Unfortunately, it’s hard to make any further suggestion without a demo project that demonstrates the issue.

Regards,
Gleb

The project is quite complex and customer related, but there are only one screen/controller effected.
Perhaps that is suffcient…
Thanks a lot!

documentSplitterScreen.zip (3.4 KB)

Hello Gleb,
can you explain what are the differences in showing non-persistent entities in datagrids and tables compared with persistent entity, or much better: do you know a sample project?
It’s quite strange, because there are >60 tables and grids within my project with persistent entities and no problems at all.
Any help would be great!

Thx.

It’s that’s the reason: the CollectionContainer hast usually as many entries in the collection as in the datagrid, and as many “idMap” entries as the collection.
But in this case the “idMap” shows alwys one entry with the value of the latest entry, that seems the reason why always this entry is marked and opened.

How can I manage to fill the idMap correct?

Capture

Hi,

Sorry for a long reply. I’ve tested DataGrid with non-persistent entity and it works as expected, i.e. I can edit an item I select. Since you’ve attached screen snippets, not a demo project that reproduces the issue, I can’t debug it.

No difference. Even standard actions work with non-persistent entities, e.i. you don’t need a custom implementation for create, edit, remove action in a simple case. The only difference is that you can’t load non-persistent entities from a DB.

I’ll be able to help you if you attache a small demo project that demonstrates the issue.

Solved: I changed the parent class of the entity from BaseIntegerIdEntity to BaseIntIdentityIdEntity and it worked.
Thanks for your time.