X-refresh in a basic repeating panel in a data grid

I’ve reviewed the post regarding x-refresh. Unfortunately it’s based on a more complex situation that I have, I think

I’m displaying table data in a very basic repeating panel in a data grid. No form in the panel, etc. As such with limited expertise, I can’t get this to work. Could I get an explanation that is likely applicable for anyone in my position simply executing the basic constructs from the quickstarts?

What’s the desired outcome sorry?

I have a table display in a repeating panel, in a data grid… pretty much out of the box solution. When a users modifies a field in a record (row), I’m changing the sort order. As such, when the operation is complete, I’d like to refresh the repeating panel so that the reordering does not require a browser refresh.

have your tried?

self.repeating_panel.items = self.repeating_panel.items

so the call to a server function to edit status is from a dropdown list on a template form, the call is performed on change. So the underlying repeating panel is not available to that template form.

A simple clone is always useful; however, it sounds like you need to reach back to the template’s parent in order to get access to the items.

You can call get_open_form().some_method_to_deal_with_your_items() from inside your template form. Or use a call to parent, but depending on the structure, that is not always a good idea.

Please see these posts for some context:



1 Like

Also if the template form’s parent is the repeating panel that you want to refresh

after the templateform has changed you could call…

self.parent.raise_event('x-refresh')
1 Like
  def intel_status_change(self, **event_args):
    anvil.server.call('edit_intel_status', self.item, self.intel_status.selected_value)
    self.parent.raise_event('x-refresh')

That does not seem to work, here’s a clone

https://anvil.works/build#clone:7M4K5UYGTVTEJRIH=M7JILPTGZ6YOX3ZJ7QMDHJYL

It is helpful for others if you share which form this is on so it saves us from searching around.

I did find the form in question though.

It seems to me like you are trying to set up a custom event.

Please read the “custom events” docs here. I believe there you will see that you are missing some basic set up code so that your refresh event exists (i.e., the event handler) before you call it.

https://anvil.works/docs/client/components#events

you also need to set and create a function to handle the event.

class home_page(home_pageTemplate):

  def __init__(self, **properties):
    # ...
    self.intels_panel.set_event_handler('x-refresh', self.refresh)
    
  def refresh(self, **event_args):
    #...
    print('refreshing')
1 Like