Datagrid Editor with cascading lookups

I have an application that has dependent fields on Cuba 7.2.20. It’s like this:

Entity Invoice:
segment → association to Segment Entity
section → association to Section Entity

Entity Segment:
section → association to Section Entity (default Section)

We have a table of Invoice entities in a DataGrid. When I click on a Row, I get LookupPickerFields for Segment and Section, as I should.

The feature I want to implement is that when a Segment is chosen, the Section field is automatically updated with the default Section from the Segment if it is null.

Ordinarily, I would do this with a ValueChangeListener on my Segment LookupPickerField. However, since it is inside the editor of a datagrid, I can’t figure out how to write it. How do I get access to the LookupPickerField inside the datagrid editor and place a custom listener there? Once the listener is executing, how does it get access to the current edited Item so it can update the section field there?

Are there any examples available?

Hello,

this is Jmix 1.5 example, but should work with CUBA 7.2
https://demo.jmix.io/sampler/#main/1/sample?id=cascading-dropdowns

Kind regards,
Mladen

Thanks, but the issue is getting access to this kind of code inside the editor of a datagrid. I have to get to the ValueChangeEvent for an auto-generated LookupPickerField generated by Cuba. Then I have to get access to the dataContainer of another auto-generated LookupPickerField in the same editor of the same datagrid row and set its value.

This is where I’m lost. How do I get access to the dataContainer for the currently edited Item in the datagrid? How can I set the value in the edited item so it shows properly in the cascading LookupPickerField and doesn’t mess up the optionsContainer attached to it?