Skip to Main Content
Spotfire Ideas Portal
Status Implemented
Product Spotfire
Created by Guest
Created on May 11, 2016

Synchronous DataTable.Refresh()

Set up (also see attached .dxp):
1. Add On Demand Data Table e.g Film, triggered by Property Control. Set "Load Automatically" to unchecked (to prevent auto loading of large amount of data)
2. Add Data Table from Existing Table in Analysis e.g. Film (UNPIVOTED)
3. Change Property Control to update Film table

We can script the refresh of the tables:
###################
myTable=myDocument.Data.Tables["Film"]
myTable.Refresh()

myTable=myDocument.Data.Tables["Film (UNPIVOTED)"]
myTable.Refresh()
############################

But this will not successfully refresh "Film (UNPIVOTED)" if "Film" takes a long time to load ("Film (UNPIVOTED)" refresh will be called before "Film" refresh is complete).

ENHANCEMENT REQUEST: a synchronous Refresh() method that will wait for the first Refresh() to complete before running

WORKAROUND: We can create a script to refresh Film (UNPIVOTED), but we need to manually create a WaitUntil function to pause execution:
#######################
from Spotfire.Dxp.Application import *
from Spotfire.Dxp.Application.Visuals import *
import time

myDocument=Application.Document

SourceTable=myDocument.Data.Tables["Film"]
SourceTable.Refresh()

def waituntil(condition, timeout, period):
mustend = time.time() + timeout
while time.time() < mustend:
if not SourceTable.Refreshing: return True
time.sleep(period)
return False

waituntil(not SourceTable.Refreshing, 5000, .25)

myTable=myDocument.Data.Tables["Film (UNPIVOTED)"]
myTable.Refresh()
#######################

Note:
- Film (UNPIVOTED) is not an On-Demand table to avoid having to pull the data from the database twice
- Film (UNPIVOTED) does not update automatically and DataTable.Refreshable property never gets set to true.
Implemented in 7.0
  • ADMIN RESPONSE
    Dec 5, 2017

    In 7.0 we added support (default true but possible to change) for tables from existing analysis to automatically update when the input table changes. With this new behavior you don't need to refresh the un-pivoted table manually. It would be done automatically after the on-demand table has changed.

    In addition if you have configured the "table from existing analysis" to use manual update (or open an old file) you can use the RefreshAsync callback API to make sure that the tables are updated in correct order.

  • Attach files
  • Guest
    Reply
    |
    Nov 9, 2017

    Please explain how/when this is implemented.