KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums KX Solutions KX Dashboards Conditional Highlight on Text

  • KX Dashboards Conditional Highlight on Text

    Posted by TickerPants on September 16, 2024 at 4:31 pm

    I have a dashboard with a text widget which will display a message depending on the state of the data. This uses a query mapper to map to the “Formatted Text” view state.

    Example
    1. “ERROR: Missing Data”
    2. “WARNING: Last load 2024.08.12”

    3. “Data up to date”

    Can I update my text widget to have conditional formatting such that if its like “ERROR” highlight the text red, if its “WARNING”, highlight orange, else green?

    TickerPants replied 1 month ago 2 Members · 4 Replies
  • 4 Replies
  • TickerPants

    Member
    September 25, 2024 at 4:30 pm

    🙁

  • ivankk

    Member
    September 26, 2024 at 10:50 am

    If the data source looks like:

    ([] kkey: enlist`message; vvalue: 1?("ERROR: Missing Data"; "WARNING: Last load 2024.08.12";"Data up to date"))

     

    I can use this template (with handlebars helper “occurrences”)

     

    {{#if (occurrences this.0.vvalue "ERROR")}}
    
       <span style="color: red">{{this.0.vvalue}}</span>
    
    {{else}}
    
       {{#if (occurrences this.0.vvalue "WARNING")}}
    
          <span style="color: orange">{{this.0.vvalue}}</span>
    
       {{else}}
    
          {{this.0.vvalue}}
    
       {{/if}}
    
    {{/if}}

     

    In this case, query mapping is not necessary.

     

    Sorry for the code formatting.., unpack the zip file and import the xml into your environment for the demo.

  • TickerPants

    Member
    October 15, 2024 at 2:10 pm

    Worked like a charm, thanks ivankk

  • TickerPants

    Member
    October 15, 2024 at 2:18 pm

    One thing though, the only way to get it to reset the value on change is to have it polling and keyed on kkey. Is there a way to “force reset” on a static query?

Log in to reply.