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.

Trigger script after data table loads

Old method

######################################
import clr
from System.Collections.Generic import List, Dictionary
from Spotfire.Dxp.Data import DataTable
from Spotfire.Dxp.Application.Scripting import ScriptDefinition
from Spotfire.Dxp.Framework.ApplicationModel import NotificationService

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

# Get second script
scriptDef = clr.Reference[ScriptDefinition]()
Document.ScriptManager.TryGetScript("yourSecondScriptName", scriptDef)
params = Dictionary[str, object]()

# Refresh Callback function
def execCallBack(exception, Document=Document, notify=notify, params=params, scriptDef=scriptDef):
if not exception:
# executes the script
Document.ScriptManager.ExecuteScript(scriptDef.ScriptCode, params)
else:
notify.AddErrorNotification("Error refreshing table(s)","Error details",str(exception))

# Get/Add table(s) to refresh
# Note that more than one table can be added to the List object. Repeat the Add() method if needed for multiple tables to refresh.

Tbls = List[DataTable]()
Tbls.Add(Document.Data.Tables['yourTableName'])

# Refresh table (new 7.0 API)
Document.Data.Tables.RefreshAsync(Tbls, execCallBack)
#############################################
Where 'yourSecondScriptName' and 'yourTableName' are respectively the name of your script and table.


new method
sourceDataTable.ReloadAllData() 

# this statement will run AFTEr the data is reloaded
print ("all done!")

Source: Perkin Elmer

No comments: