Aim:
We do want to refresh all the data table used in the dashboard to be reloaded based on your refresh/reload.
Steps 1:
As of now for the demo, established a file based connection. Please find the attached file used for the demo.
Step 2:
For Example, Take a file consisting of 840 rows.
After loading the data into spotfire, add a new text area and a button from the insert action control menu.
Select script from the new window as shown below.
Step 3
Enter display text name (Refresh)
Step 4
Click on the New Button
Step 5
Enter Script Name (Refresh)
Enter the script attached below in the scripting area.
#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
# 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)
Step 6
The red color line in above script is a parameter.
Since here we are using only one table, we will parameterize this table alone as show below
For this click on Add button.
Step 7
Now you are done with the on-demand refresh through button click.
Step 8
Now go to above data table and remove few line of row.
Step 9
Click on refresh button.
Before Refresh
After Refresh
Your Number of row willchange.
Your Number of row willchange.