Refresh / Reload DataTables

#Method 1
# Refresh one table
if table.IsRefreshable and table.NeedsRefresh:

# Refresh all tables
for t in Document.Data.Tables:
   if t.IsRefreshable and t.NeedsRefresh:

#Method 2
import clr
from System.Collections.Generic import List, Dictionary
from Spotfire.Dxp.Data import DataTable
from Spotfire.Dxp.Framework.ApplicationModel import NotificationService

# Empty list to hold DataTables
Tbls = List[DataTable]()

Tbls.Add(dt1) #dt1 a DataTable string parameter 
Tbls.Add(dt2) #dt2 a DataTable string parameter 
Tbls.Add(dt3) #dt3 a DataTable string parameter 

# Notification service
notify = Application.GetService[NotificationService]();

# Execute something after tables are loaded
def afterLoad(exception, Document=Document, notify=notify):
if not exception:
print "OK"
notify.AddErrorNotification("Error refreshing table(s)","Error details",str(exception))

# Refresh table(s)
Document.Data.Tables.RefreshAsync(Tbls, afterLoad)


Stéphane Griguer said...

Hi, does someone know how to reload Data table programmatically, how it show above, but WITH PROMPTS define from the InformationLinks of the DataTable?
Thanks for you help.

Aniket Koyande said...

Hi Stéphane, did you figure out how to do it? Thanks.

Nicole Camden said...

I'd like to know as well.

Ajay Choudhary said...

Hi Does any one know why Reload Data not working on Webplayer? I have added one button and try reload data, it is working on desktop version but not on WebPlayer....

Eric Flores said...

The scripts above reload a primary table that is linked to an external source (on both Desktop and Webplayer), but it will not reload the data for a Pivot table that is based on the primary table (internal). Actually, that pivot table never turns the NeedRefresh flag on.
I have been able to work it around in the Desktop by selecting menu File/Reload Data, but I can't find this optionin the Webplayer.