Why no refresh_data_bindings() for write back data binding?

I don’t see how the addition of a “refresh_data_bindings_for_write_backs” would alter existing behaviour.

What’s the use case where you need to populate everything in self.item at the same time? With writeback self.item is always up-to-date, especially if the fields have not changed.

Sorry, still struggling to understand in what situation this is needed.

If it’s the case that you want self.item updated on events other than lost focus (e.g. field changed), that makes sense, since there is a period while the user is typing when self.item and a single field contents don’t match.

Or maybe it’s that you want writeback to happen even when you programmatically change the contents of a field? That also makes sense, since writeback doesn’t trigger then. I could see a way to programmatically trigger writeback useful in that situation.

Also, if at any point I’m just so far off base that it’s clear I’m never going to get it, feel free to say so. Not trying to generate any frustration here, just trying to wrap my mind around the proposed feature.

1 Like

That is indeed the case: ideally I’d like to have the whole self.item updated on each field change.

For those following this thread - I’ve added a feature to the augment library. The latest version can be found within the anvil-extras package (This feature will get added in the next version release)

Anvilistas - The Greatest Hits

It overloads the trigger method that already existed when using that library. It aims to address the issue highlighted in this thread that it’s not possible to trigger a writeback on TextBox or TextArea change events and creating a custom component to do the same thing is a little cumbersome

It can be used as follows:

from anvil_extras import augment

def textbox_change(self, **event_args):
    event_args['sender'].trigger('writeback')

This will work on any component that has writeback properties set.

3 Likes