Best way to interact with multiple repeating panel items? πŸ€·β€β™‚οΈ

I am building my first anvil app that will manage orders for a company. I have a main form with a repeating panel that contains a summary of all the current orders. When a user clicks on one of them it will open the order details form. The user can then make changes and return back to the main order form This is all fine.

I want the ability for a user to be able to select multiple orders, and that will in turn open up the first selected order, then once they are finished with it, the app will open the next one they selected. This I am struggling with.

I have setup an event handler and call it on each of the repeating panel items:
self.repeating_panel_items.raise_event_on_children("x-openmulti")

With the event including this code for now:

def openmulti(self, **event_args):
    if self.check_box_1.checked == True:
      get_open_form().content_panel.clear()
      get_open_form().content_panel.add_component(OrderDetail(item=item))

This checks if that item is checked or not. And if it is ticked it will open up the order detail form. But all this ends up doing is opening them all up and only shows the final order that was checked.

How do I wait for the order detail form to be closed before moving onto the next one?

Any help or pointers on where I can get hep will greatly be appreciated :slight_smile:

Suggestion: a two-stage process.

  1. Collect the selected items into a list
  2. Iterate over the list one item at a time.

Each item (on-screen) will need to provide a β€œNext” button (or equivalent), so that the window (and your loop) knows when to move on to the next item in the list.

1 Like

Here is one way. When rows are selected in the row template, I store them on the main form. Then, when I want to view the selected rows, my main form passes the selections to a new form. For simplicity, I let a data grid handle the pagination.

There are many ways to do this but hopefully this can help to get you started.

clone:
https://anvil.works/build#clone:7YVTONL5XI5TX6YW=F3DTCMA52HFILGCO7MSIAMGV

4 Likes

Thanks @p.colbert and @alcampopiano I will try those approaches as that seems to make sense in my head :slight_smile:

Particularly thanks to @alcampopiano for the demo app… you also taught me a much better way to pass info to a parent using tags :+1:

2 Likes