Refresh Power Table

Is there a way to refresh the power table for the client once a query has run? As of right now, the client has to navigate to another window then go back for the power table to refresh with the new data even though the dataset has already been updated. I have tried the db.refresh script below and well did not work as expected. Any way to get around this?

system.db.refresh(event.source.parent.getComponent('criticalWells'), "data")

You didn’t post the script you said you tried but the system.db.refresh() function should be what you want.

How are you passing the data to your table? Is it via a binding query binding? Or some form of scripting?

I have a query binding on a custom property root container, then have expression binding passing it in on the actual powertable data dataset.

Now I see the script but it wasn’t there when I looked the first time. Is there a reason your doing the biding on a custom property and not just on the data section of the power table?

With passing it through an expression, the refresh on data for the power table won’t work. It would trigger the expression to run again which I don’t believe would cause the custom property to refresh. Is there a reason it has to be done that way?

Yes, I went back and edited the post after your comment. The reason for passing in via expression is to be able to sort down to certain areas of the field.

If your doing it for sorting why don’t you use “ORDER BY” in your query to sort the data during the query? Then you could bind directly to the table allowing the system.db.refresh() to work.

I also mispoke above, the system.db.refresh() is only for refreshing a query so it would do nothing to your expression.

Use system.db.refresh(...., "myCustomPropertyName"). You have to specify the property that has the query of interest. When that result comes in, it will flow to any dependent expressions.

What you tried “worked”, but just told the data property to run its expression again, with the existing query data.

Just went back and read that and realized how vague it was. We have 4 custom properties, each are binded to a different query. Then we have a expression that chooses which one by a checkboxes from the screen.

Not true. It refreshes any binding. But refreshing an expression just re-runs it with the data it already has access to.

pturmel, I wasn’t sure if that would work or not since he said the custom properties are on the root container. I couldn’t try it right now to find out.

Then the .getComponent() would also be left out. The root container of a window is a valid component as far as system.db.refresh() is concerned.

1 Like

I’d try what pturmel mentioned.

At the same time though, if you are running 4 different queries that return similar data like you mentioned, I’d have to wonder could you pass in a parameter to bring it down to one query. If all the queries are similar enough it would be easy to do and cut back the calls to your database when the page loads.

Good to know. I haven’t run into anything where I needed to treat the root container as a component but good to know it can be.

I am working to try pturmel’s suggestion right now, but that is sorta what was crossing my mind. Potentially just creating another parameter to pass into the query vs having 4 separate ones.

If you can I personally would. You could use your expression to determine the variable that is passed in based on your check boxes. Or a series of expression bindings linked to each check box if needed.

If more than one could be checked at one time then it would probably need to be a series of them doing an OR in your query to look for the data that is selected. If its the full value in a field that your filtering by you can have the expression make it that when the box is checked and as long as you have no blanks in the column you can make it filter for null to ignore that filter.

Then your query could be run from the table itself or if you want it in a custom property it can be directly linked to the table.

It also has the added benefit of you only have one query to maintain instead of 4 if a change is needed later.

Maybe I was doing something wrong, but I could not get system.db.refresh() to work no matter where I put it.

I did find a solution, not sure if it is the best way to do it, but does get the job done. Basically the the primary use is I have a full list of sites on the left power table and just specified sites on the right power table. I have a add button and remove button. I added the below to the mouse released function to both and seems to work exactly how I need it to.

system.nav.closeParentWindow(event)
window = system.nav.openWindow('GasControl/Popups/Manage Critical Wells')

I appreciate all the help on this and @bpreston I may still look at using parameter with single query instead of 4.

What did/does your code look like when using the system.db.refresh()?

If you have a custom property on the root container called “MyDataQuery” then your system.db.refresh will look something like this:

system.db.refresh(event.source.parent,"MyDataQuery")

1 Like