Hi,
I've been pulling my hair out with this one for a while. I'm probably missing something really simple.
I have a view in perspective, which contains a table. The table is populated with data from several different sources, so I have used a script to build the dataset myself.
To update the data in the table I used a message handler script on the table itself. I then tested that the script worked by adding a button which sends a message to the message handler. This works fine and the table data updates from the button.
The main view in the project uses a tab container, with different embedded views within each tab. I wanted to ensure that the table data is up-to-date, automatically when its tab is selected, rather than using a button. To do this, I have a change script on the 'currentTabIndex' property of the tab container. This script sends the same message to the table message handler as the button does.
I have print statements at various points in the script, so I can see that it is definitely running, however, the data shown in the table does not update when the message is received from the property change event. The data in the table will only update off the button.
The message handler scope is set to session. The first few lines of script as follows:
# set up error logger
import sys
import traceback
logger = system.util.getLogger("update quote table message handler")
scriptName = "update quote table message handler"
try:
system.perspective.print("fired from: " + str(payload['source']))
system.perspective.print("this is the update quote table(table) message script: first line")
# get external calibrations due soon
now = system.date.now()
dueBefore = system.date.format(system.date.addMonths(now, 2),"yyyy-MM-01")
data = system.db.runNamedQuery("externalQuotes/externalDue",{"dueBefore":dueBefore})
pyData = system.dataset.toPyDataSet(data)
The button sends this message:
payload={'source':'update table onClick'}
system.perspective.sendMessage("updateQuoteTable",payload,scope='session')
The property change sript sends this message:
payload = {'source':'tabIndexChangeEvent'}
system.perspective.sendMessage("updateQuoteTable",payload,scope='session')
The only difference being the payload, so i can see where the message was received from.
The console shows that the script is firing from the tab index change event and running to completion:
11:07:38.942 [Browser Thread: a0f567c5-1801-4ebb-9559-c80ffb61fa5c] INFO Perspective.Designer.Workspace - fired from: tabIndexChangeEvent
11:07:38.942 [Browser Thread: a0f567c5-1801-4ebb-9559-c80ffb61fa5c] INFO Perspective.Designer.Workspace - this is the update quote table(table) message script: first line
11:07:39.009 [Browser Thread: a0f567c5-1801-4ebb-9559-c80ffb61fa5c] INFO Perspective.Designer.Workspace - this is the update quote table(table) message script: quotes already sent query ran
11:07:39.009 [Browser Thread: a0f567c5-1801-4ebb-9559-c80ffb61fa5c] INFO Perspective.Designer.Workspace - this is the update quote table(table) message script: company contact tag read
11:07:39.031 [Browser Thread: a0f567c5-1801-4ebb-9559-c80ffb61fa5c] INFO Perspective.Designer.Workspace - this is the update quote table(table) message script: dataset updated with supplier emails
11:07:39.031 [Browser Thread: a0f567c5-1801-4ebb-9559-c80ffb61fa5c] INFO Perspective.Designer.Workspace - this is the update quote table(table) message script: row styling added
11:07:39.031 [Browser Thread: a0f567c5-1801-4ebb-9559-c80ffb61fa5c] INFO Perspective.Designer.Workspace - this is the update quote table(table) message script: table data updated
11:07:39.032 [Browser Thread: a0f567c5-1801-4ebb-9559-c80ffb61fa5c] INFO Perspective.Designer.Workspace - this is the update quote table(table) message script: end of script
I thought it might be something to do with not having the focus on the view, so I tried setting the focus in the script as well, but it didn't make a difference.
Sorry it's a long post. I've tried to include as much info as I can. Anyone have any ideas what is going wrong here?
Thanks,
Leigh