The key for Save/Cancel is to use a temporary list
in place of the real one. That way, if the user Cancels, the original remains unchanged.
from copy import deepcopy
- Create the temporary list:
self.edit_buffer = deepcopy(self.item['location_details']['sites'])
- bind the Repeating Panel’s enclosing Data Grid (not the Repeating Panel!) to the copy, i.e., to
self.edit_buffer
. - Bind each of the Grid’s columns to its corresponding
dict
entry, by name (key). For example:
So your Keys would besite_name
,address_1
, etc. - At run-time, the Data Grid will bind each instance of the Repeating Panel to its own list element for you, so you should not bind the Panel itself.
- Within the Repeating Panel, bind each editable field to its value by name (key):
item[
key]
For example: - On Save, re-assign
so['sites'] = self.item['location_details']['sites']
, and write it back to the database. - On Cancel, leave
self.item['location_details']['sites']
unchanged.
I hope this clarifies matters!