Jump to content
  • Spotfire: Dynamically Hide and Show Controls in the Text Area Using IronPython Scripting


    The following is a simple way to hide and show text area controls to allow a more dynamic way to handle input. One caveat is that the hidden control will still occupy a certain amount of space in the area, hidden or not

    #Please note, this article may contain incorrect URLs due to the Spotfire Community migration. 

    Introduction

    The following is a simple way to hide and show text area controls to allow a more dynamic way to handle input. One caveat is that the hidden control will still occupy a certain amount of space in the area, hidden or not. The Spotfire controls can be seen in the text area HTML code as this:

     <SpotfireControlid="715d19d1264845b38a51a2cf29e67730" />

    Each control needs to be wrapped in a tag that allows using a hide property (default to visible).
     <div style="visibility: visible;"><SpotfireControlid="715d19d1264845b38a51a2cf29e67730" /></div>
     

    A user can modify the HtmlTextArea HtmlContent dynamically without losing the Spotfire controls. This example only uses a very simple replace scheme to change the area. More advanced solutions using parsing and regular expressions would probably be a better idea in most cases, especially if multiple hidden controls are used.

    Code Sample

     # Code to replace the visibility property:
     from Spotfire.Dxp.Application.Visuals import HtmlTextArea
     
     for vis in Document.ActivePageReference.Visuals:
         if vis.Title == 'Text Area':
             html = vis.As[HtmlTextArea]().HtmlContent
             
             if 'hidden' in html:
                 vis.As[HtmlTextArea]().HtmlContent = html.Replace('hidden','visible')
             else:
                 vis.As[HtmlTextArea]().HtmlContent = html.Replace('visible','hidden')
     

    References

    License:    TIBCO BSD-Style License
     

    Back to IronPyton Scripting in TIBCO Spotfire Examples:  https://community.spotfire.com/s/article/IronPython-Scripting-in-TIBCO-Spotfire

     

     

    • Like 1

    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...