Refresh Binding on Table

ok, I have a Table Table_BrassTag this table has a button Save when I click on this button a popup appears, in this popup, I add some data, click on Save on popup another popup opens with a confirm and cancel button when I click on the Confirm button. The data gets saved into the database via a Message Handler (Thanks to @pascal.fragnoud ).
Now I want to refresh the binding of Table_BrassTag how do I achieve it?

self.getChild("Tbl_BrassTag").refreshBinding("props.data")

It seems you answered your own question?

1 Like

I would put a message handler on the table itself with

def onMessageReceived(self, payload):
	# implement your handler here
	self.refreshBinding("props.data")

It doesn't work actually.

def onMessageReceived(self, payload):
        if q:
            system.db.runPrepUpdate(q, v, database_name)
            self.getChild("Tbl_BrassTag").refreshBinding("props.data")

Check the error:

Error running Popup/Add_BrassTag@PL5dgDy-E/root.onMessageReceived(self, payload): Traceback (most recent call last): File "<function:onMessageReceived>", line 28, in onMessageReceived AttributeError: 'NoneType' object has no attribute 'refreshBinding'

Probably best to follow @Kevin_Flener's advice.

Will the table receive the message second popup?
Table>Popup1>Popup2:Confirm, Popup1:Confirm Received>Table:Confirm Received From Popup2

It should. I have a delete confirmation popup that sends a message to my table to refresh the data binding and it works as expected.

As long as you have the correct Listen scope.

Isn't the message handler that does the database operation on the table ?
The whole point of my suggestions in the previous threads was to have the message handler on the table.

edit: Actually I guess you have another table in the first popup ? And you put the handler here ?
Why exactly are there 2 popups ? Shouldn't the first one be enough ?

This made me believe the message handler was on the container for the table.

self.getChild("Tbl_BrassTag")...

If the handler is already on the table then he should just remove that part to make it like this, right?

def onMessageReceived(self, payload):
        if q:
            system.db.runPrepUpdate(q, v, database_name)
            self.refreshBinding("props.data")

I think there's another table in the first popup, and that the message handler is there...
But he wants to refresh the table that's in the base view.

The First one is for Inserting the data, the second one is for confirmation.

Yes, the message handler is on the container of the Main Table.

Well then you can do self.refreshBinding('props.data') right after the db opertation, as suggested above.

Exactly.
So, Main View With Table (View A) to be refreshed. Here we have a button it will open a popup (View B), on this popup we have another table that we will use to insert the data, upon inserting and Pressing Confirm, another popup(View C) will open this will have a Confirm and Cancel Button. When We will click on the Confirm button. Data will be saved into the database via message handler on the Popup One (View B). Once data is Saved, this Popup will be closed and after closing of this Popup (View B) user will be redirected to Main View with Table (View A) I want to refresh the binding of this table as this table is showing the data has been inserted from View B.

The message handler should be on View A, all of the updating and everything should be done there. When you are done updating the DB, you call self.refreshBinding('props.data').

IMHO, the second popup is needlessly complicating the UI and will become a headache to the user.

Just put the confirm and cancel buttons on the View B popup. If the confirm button is pressed, you send the message to View A and close the popup. If the cancel button is pressed, you just close View B and nothing else happens. There is no reason for the 2nd popup, which is only adding the number of clicks needed by the user to accomplish their goal.

I am sure your solution is more practical but unfortunately I cannot alter the workflow.

Put aside the fact that the second popup is unneeded.

The message handler should still be on the main view.

Even if you just put an additional message handler on the main view that's only purpose is to refresh the table.