Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

GUIDE: chains of elements, problem with updating the last one

1 vue (au cours des 30 derniers jours)
Lorenzo
Lorenzo le 3 Juil 2013
Clôturé : MATLAB Answer Bot le 20 Août 2021
Dear all; I'm creating a user interface and I'm having some doubts. My user interface has (at least) two tables and two text boxes and the situation is the following:
The user enters some data into the first table, these data are read as soon as they are entered, a calculation is performed and the result is written to the first text box. After that, the user enters some data into the second table, these data are read as soon as they are entered and a calculation involving these data and the number written in the first text box is performed and the result is written to the second text box and this is the final result of the whole GUI. Everything works ok so far.
Now, let's imagine that the user, once he/she has updated the second table, finds a mistake in the first table. So he/she edits the data in the first table. At this point the result of the first calculation is written to the first text box but the final result is not updated in the second text box since the data in the second table weren't updated. In order to have un updated final result the user would have to hit enter for one of the second table cell.
Is there any way to overcome this issue?
Just to be clearer, the code that I have at the moment is:
--table1_edit
----calculation with the data in table1
----results written to textbox1
--table2_edit
----calculation with the data in table1 and the value of textbox1
----results written to textbox2
and what I would probably need (and I don't know how to achieve) is:
--table1_edit
----calculation with the data in table1
----results written to textbox1
--table2_edit OR table1_edit
----calculation with the data in table1 and the value of textbox1
----results written to textbox2
Thank you all for your help!
Regards
Lorenzo

Réponses (2)

Evan
Evan le 3 Juil 2013
Modifié(e) : Evan le 3 Juil 2013
I would create a "core" function which does the calculation, and then call that core function in the CellEditCallback for both of your tables. This way, you don't have to have duplicate code in your different callbacks and the editboxes will stay up-to-date even if the user goes back and makes a change in the first table.
Of course, in this "core" function, you'd have to check to make sure that the second table had data entered into it before trying to update the second editbox, just so that the function isn't trying to do operations that can't yet be done, for example when the user first enters data into the first table.

Lorenzo
Lorenzo le 4 Juil 2013
Thanks Evan. Your idea looks nice. The only problem is that in my description above I slightly simplified the situation as instead of having 2 tables I actually have 10 and I hoped there was a simpler way of doing this thing....
  1 commentaire
Jan
Jan le 4 Juil 2013
Please post comments in the comment section, not as an answer. Thanks.

Cette question est clôturée.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by