Every row of that column, has to be a PopupView that dynamically loading nested datasource in a Table.
I only find a manual way to get it, but few problems left:
The dynamic loading of content in
PopupView
is not success. Seems it using lazying fetch. The sampler one has such loading effect, just like an active dynamic fetch.
2. For the lambda expression of
addGeneratedColumn
in sampler, don’t know how to reference the entity of that row? I mean how to rewrite the generator below to a lambda function?
3. Seems the popupView is bound with selected row(entity), it means, if you just opened the table, nothing has been selected, the popup could not fetch related data, if you select row 2, then every popup of other row will show exactly the same content from row2, except you chose specific row. One word, you have to chose specific row, then click popup on that row, then you got the expected behaviour.
4. The original idea is just to hover a hint text like
5 phones
then popup a table shows that five phones, even you don’t have to click.
I pointed this function as a column generator in the column properties editor of table in CUBA’s screen editor.
The reason for such behavior is a nested datasource, which you use to populate a table in PopupView. Nested datasource contains items associated with a currently selected item in table connected with master datasource. To solve this problem you can build custom datasource in addGeneratedColumn and filter Phone entities with currently passed Contact entity. For example:
CollectionDatasource phonesDs = new DsBuilder(getDsContext())
.setJavaClass(Phone.class)
.setViewName(View.LOCAL)
.setId("phonesDs" + entity.getId())
.buildCollectionDatasource();
phonesDs.setQuery("select p from demo$Phone p where p.contact.id = '" + entity.getId() + "'");
phonesTable.setDatasource(phonesDs);
To show information by mouse hover you can use a label with html content for its description. For example:
Please note, that Label#setCaption does nothing. To set a value to a label you have to use Label#setValue method instead.
Let me ask you a question. Do you really need a table inside a PopupView? I would recommend using HTML content inside a PopupView as its more lightweight than a table. Below my version of your screen controller: