Customer Banners (Ads) - SpiceUp. AX and SpotfireX Disclaimer



If you find this site useful and you want to support, buy me a coffee   to keep this site alive and without ads.

Refresh / Reload DataTables

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


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




#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:
Document.Properties["lastReload"]
print "OK"
else:
notify.AddErrorNotification("Error refreshing table(s)","Error details",str(exception))

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



5 comments:

perlinpinpin 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.
Stéphane

Anonymous said...

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

Unknown said...

I'd like to know as well.

Unknown 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.