How to populate sub form fields with a database select

Thanks so much, it works!!! Thats definitely a hack I’m going to be using elsewhere in this project :slight_smile:

Seeing that screenshot, I think you’d be better off with a single data grid that had multiple rows. You’re doing a lot more work with the multiple data grids than you need to.

You could build a list of dictionaries like this:

items = [
    {'type': 'Cancellation', 'amount': self.totalcancellation},
    {'type': 'Baggage', 'amount': self.totalbaggage},
    {'type': 'Single Article Limit', 'amount': self.totalarticles},
    etc
]

Then set that into the repeating panel:

self.repeating_panel_1.items = items

As long as your row template used data bindings correctly (e.g. the label where you currently have the types would bind its text property to `self.item[‘type’]), everything would fill in automatically. Long-term it’d be less hassle to maintain and add new rows to the data grid.

You’d also want an entry in your dictionary for which icon image to use.

It doesn’t make much difference for this situation, since you have it working, but if you have similar situations in the future, work out how to use a single data grid. It’ll save effort.

1 Like