Update editable table field from another field

Hi Cuba team,

I’ve got a composition table that is editable. Please see the following screenshot for reference:

The Invoice Items table is set as editable to keep clicks down so the users won’t have to go to the Invoice Item editor to change the Actual Charge attribute. I’m looking for a way to manipulate the Charge Up/Down field based on editing the Actual Charge field for each table entry. I haven’t been able to find the search terms to locate the information I’m looking for. What I need is to update the Actual Charge field manually and have it subtract the value from the Estimate field and update the Charge Up/Down field after changing the value. Do I need to set the Charge Up/Down field to editable?

The main problem is that I’m not sure how to manipulate the value of Charge Up/Down when manually changing the Actual Charge value for each entry.

Any information or links to examples are much appreciated.

Thanks, and let me know if more information is needed,


CUBA UI has a two-side data binding.
It means that if an entity is located in the data container which is bound to some UI components - then:
a) every value change of the component is written to the entity
b) every change of the entity attribute is immediately displayed in the UI component.

To listen for the changes in the Actual Charges field, you need to subscribe to the ItemPropertyChangedEvent of the collection container that contains invoice items.

See InstanceContainer - CUBA Platform. Developer’s Manual

So the algorithm is:

  1. Subscribe to the ItemPropertyChangedEvent of the invoice items container
  2. Check that event.getProperty() equals to the actualCharge attribute name.
  3. Recalculate Charge Up/Down field, write the value to the event.getItem() entity
  4. Corresponding table cell will be repainted automatically.
1 Like

Thank you for the help,

This is exactly what I needed.