Table and paintable canvas Object refresh

I have a simple question.
I use things like tables and the paintable canvas, and find i have to use a kludge to get them to refresh when I want them to. Is it possible to add a refresh method? I dislike using kludges because they may not work in future versions.


Use the system.db.refresh() function. That’s the documented and supported method to refresh things on demand. (As opposed to a polling binding, etc.) Although it was created to refresh dataset bindings, it actually refreshes any binding.

1 Like

Thanks. I’ll try it, I assumed the dataset had to come from a database for that function.

It didn’t work. here is the message:

WARN [PMITable-AWT-EventQueue-0] system.db.refresh() was unable to find a refresh-compatible property binding on

The table dataset is initally fed from a csv file and there is no binding.
What I do now, is:

event.source.parent.getComponent(‘Table’).selectedRow = 0
event.source.parent.getComponent(‘Table’).selectedRow = 1
event.source.parent.getComponent(‘Table’).selectedRow = svr

which works regardless of which row is currently selected.

for the paintable canvas, I have a custom property I drive a value to.

I guess I don’t understand what you are trying to refresh on the table. I presumed the table data was coming from a binding. Since it’s static, I don’t see what there is to refresh.

I think I see the problem. Lets say that for a chart (not easy chart) we have binded a button to the tooltips property. If the property is set to True when the client/chart is shown, then the chart will always have the tooltip active even if we deactivated it with the button. A refresh of the chart/table would be needed to update these kind of properties. Is this the problem you have ? I currently having a similar issue, if I find the soluction Ill let you know.

Pretty simple to explain:
updating a table with tabledata.setValueAt(row,column,value) sets the value, but you don’t see it until something else causes the table to refresh.

Also, for the paintable canvas, if you draw on it you have to change a bound item to get it to refresh and show the drawing.

For the table update, I don’t recognize the function you mentioned - do you mean “system.dataset.setValue(dataset, rowIndex, columnName, value)”?

For the paintable canvas - just call its repaint method any time. So if you were to do it from any extension function, just use event.source.repaint(). You don’t need to pass it any sort of event, it’ll take care of that.

1 Like

You need to repaint. the table, as well.

table = event.source.parent.getComponent('Table'),column,value)


EDIT: I was writing as Phil’s post below came in, but it stands that best practice is to use system.dataset.setValue() to create a new dataset with the updated value, then write it back to the table.

1 Like

setValueAt() is a method built into the dataset itself.

There’s your problem. You are modifying a dataset in place. That won’t generate a property change event, and therefore won’t cause any update. That method is not part of the Dataset interface, and is actually intended only for construction of a dataset prior to assignment anywhere. For your code to work properly going forward, you need to use system.dataset.setValue(), and assign its return value back to the data property of the table. Like so:

table = event.source
# compute/obtain row, col, newvalue ..... = system.dataset.setValue(, row, col, newvalue)
1 Like

Just add a custom property to the paintable canvas, unbound, and change it via scripting whenever you want to redraw. Could be as simple as a boolean that you toggle.

Thank you all. Both methods worked for me.
As recommended I’ll use
system.dataset.setValue(, row, col, newvalue)

as for the paintable canvas, that is what I’ve been doing, I just thought it felt like a work around, but I’ll just be happy it works.