How to - Show a "loading..." prompt when reloading external data
Supported Version: Spotfire 7.0 or later
A guide on how to get a refresh indicator which looks something like the below, note however that we cannot trap the "Viz redrawn" event as part of this hence the slight delay after the bar vanishing and the table updating:
- Add a progress indicator inside a div; hidden by default
- Use a html button which calls JS to show the progress indicator, and then triggers python by forcing a click event on a second spotfire button
- The Iron Python uses a special RefreshAsync method introduced in Spotfire 7 to manipulate html after tables have refreshed
- Use a known workaround to force the html to redraw (force a new whitespace at the end)
Attached you'll find a zip containing all the files needed to get started:
- Sample html
- Iron Python layer
- An optional SQL script which fabricates a table taking two seconds to load (can be set up using an MSSQL connection); this is purely for testing purposes.
Each file contains comments to walk you through setting this up, however the full instructions are as follows:
- Extract the contents of the zip file.
- Create a text area if you don't have one on the page yet.
- Go into Document > Properties, and create a new Iron Python script
- Change YOUR_TABLE_NAME to the relevant table (and add more if required)
- Add a script parameter with name=vis and type=visualization
- On your text area, "Edit html" and:
- copy and paste the contents of Reloader.html into it
- Insert a spotfire action button where prompted to do so inside the html and trigger the python script, passing in the text area as the script parameter
- (Optional) Change the <Style> section to contain your own spinner, of which many can be found here
- Save and close the Spotfire html editor
Don't forget that you can use any refresh indicator you want inside the provided "loading" div!
We hope you find this page useful. Do you have a challenge we could help with? Get in touch!