Creating Aliases for Spotfire IDs

  • Do you find dealing with long Spotfire ids in text areas annoying?
  • Would you like an easier way to reference and work with them?
  • Have you ever tried creating aliases?

 

You might be asking, what is an alias?  Well, an alias is simply another name or reference for something within the code.  In this case, we want to create an alias for the Spotfire ids that the software.  The assigned ids are long and can be difficult to work with, so we create aliases for ease of use.  Ruths.ai recently published two templates that demonstrate the use of aliases. You can download them from the links below.

Show Hide Controls with JavaScript  (updated links coming soon)

Pass Calculated Value to Property Control

Using Aliases — HTML Example

In the example shown below, a jQuery script passes a calculated value to a property control.  The id attribute creates the alias for the Spotfire id within the span tag.  Then, jQuery script calls or references the aliases. This is much easier than copying and pasting the Spotfire ids.

HTML Aliases

Using Aliases — JavaScript Example

In the example shown below, JavaScript code controls the visibility of two different drop-down menus based upon the value of a third drop-down menu.  The variable statement defines the Spotfire ids as variables.  You can learn more about var at this link. In this case, comments have also been added the at the top to further clarify which control is which.  It can get confusing so quickly!

JavaScript Aliases

 

Other Tips

If you are new to working with the HTML editor in Spotfire, you might not know that you can click on the text area element on the right in the list, and it will highlight where that control is at in the text area HTML.  Also, you can double-click on the id, and Spotfire will highlight the entire id so it can be copied and pasted.

Working with Aliases

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *