<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to hide HTML in panel when multiple tokens are set? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-hide-HTML-in-panel-when-multiple-tokens-are-set/m-p/307454#M19595</link>
    <description>&lt;P&gt;Anytime &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Aug 2017 07:14:28 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-08-30T07:14:28Z</dc:date>
    <item>
      <title>How to hide HTML in panel when multiple tokens are set?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-hide-HTML-in-panel-when-multiple-tokens-are-set/m-p/307450#M19591</link>
      <description>&lt;P&gt;hello,&lt;BR /&gt;
I have a panel with  tag like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;panel&amp;gt;  
&amp;lt;html rejects="$first$,$second$"&amp;gt;
 ....text....  
&amp;lt;/html&amp;gt;  
&amp;lt;/panel&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have two tokens based on different searches in the dashboard.&lt;BR /&gt;
I want the HTML to be hidden when &lt;STRONG&gt;both&lt;/STRONG&gt; the token are set.&lt;BR /&gt;
how can I do this?&lt;BR /&gt;
thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2017 14:15:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-hide-HTML-in-panel-when-multiple-tokens-are-set/m-p/307450#M19591</guid>
      <dc:creator>avivn</dc:creator>
      <dc:date>2017-08-28T14:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to hide HTML in panel when multiple tokens are set?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-hide-HTML-in-panel-when-multiple-tokens-are-set/m-p/307451#M19592</link>
      <description>&lt;P&gt;@avivn, can you add more details on what event is setting tokens $first$ and $second$ in your dashboard?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2017 17:33:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-hide-HTML-in-panel-when-multiple-tokens-are-set/m-p/307451#M19592</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-08-28T17:33:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to hide HTML in panel when multiple tokens are set?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-hide-HTML-in-panel-when-multiple-tokens-are-set/m-p/307452#M19593</link>
      <description>&lt;P&gt;@avivn, Behavior of &lt;CODE&gt;depends&lt;/CODE&gt; attribute and &lt;CODE&gt;rejects&lt;/CODE&gt; attributes with multiple tokens are different.&lt;/P&gt;

&lt;P&gt;For &lt;CODE&gt;depends&lt;/CODE&gt; multiple tokens work like &lt;CODE&gt;AND&lt;/CODE&gt;, i.e. element (like row, panel, html, input) with depends shows up only when all tokens are &lt;CODE&gt;set&lt;/CODE&gt;. On the other hand, for &lt;CODE&gt;rejects&lt;/CODE&gt; multiple tokens work like &lt;CODE&gt;OR&lt;/CODE&gt;, i.e. element with rejects gets hidden even if there is one token which is &lt;CODE&gt;unset&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;So instead of using rejects, you would need to implement your own logic using Simple XML JavaScript Extension in your dashboard.&lt;/P&gt;

&lt;P&gt;PS: Since the following required Token Handler, you need to know whether tokens belong to &lt;CODE&gt;default&lt;/CODE&gt; or &lt;CODE&gt;submitted&lt;/CODE&gt; model in your dashboard/form. Refer to documentation: &lt;A href="http://dev.splunk.com/view/SP-CAAAEW2"&gt;http://dev.splunk.com/view/SP-CAAAEW2&lt;/A&gt;. &lt;BR /&gt;
I have used &lt;STRONG&gt;default&lt;/STRONG&gt; event handler in my case to code change in token values. Since I have used token's change event handler, assumption is both tokens will not be set on dashboard/form load. : &lt;A href="http://dev.splunk.com/view/webframework-codeexamples/SP-CAAAE5J"&gt;http://dev.splunk.com/view/webframework-codeexamples/SP-CAAAE5J&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/3417iC36323E05361EC09/image-size/large?v=v2&amp;amp;px=999" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Step 1:&lt;/STRONG&gt; Save the following file as &lt;CODE&gt;hide_html_on_multiple_tokens.js&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    "splunkjs/mvc",
    "jquery"
    ],
    function(
        mvc,
        $
        ) {
            //mvc.Components.get() function to get all default Tokens
                var defaultTokenModel = mvc.Components.get("default");

                defaultTokenModel.on("change:first",function(newTokFirst,first){            
                    console.log("first: ",first);
                    var tokSecond= defaultTokenModel.get("second");                 
                    console.log("tokSecond: ",tokSecond);
                    if (tokSecond===undefined || first===undefined){
                        $("#html1").show();
                    }else{
                        $("#html1").hide();
                    }
                });

                defaultTokenModel.on("change:second",function(newTokSecond,second){
                    console.log("second: ",second);
                    var tokFirst= defaultTokenModel.get("first");                   
                    console.log("tokFirst: ",tokFirst);
                    if (tokFirst===undefined || second===undefined){
                        $("#html1").show();
                    }else{
                        $("#html1").hide();
                    }
                });
        }
    );
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Step 2:&lt;/STRONG&gt; Create a SimpleXML form with above JS and &lt;STRONG&gt;radio&lt;/STRONG&gt; input to &lt;STRONG&gt;set&lt;/STRONG&gt; and &lt;STRONG&gt;unset&lt;/STRONG&gt; two tokens to test whether HTML panel gets hidden or not. PS: jQuery in this example uses HTML &lt;CODE&gt;id&lt;/CODE&gt; attribute i.e. &lt;CODE&gt;html1&lt;/CODE&gt; to &lt;CODE&gt;hide()&lt;/CODE&gt; or &lt;CODE&gt;show()&lt;/CODE&gt;the same:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form script="hide_html_on_multiple_tokens.js"&amp;gt;
  &amp;lt;label&amp;gt;Hide HTML Panel on setting both first and second tokens&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="radio" token="tokenChanges"&amp;gt;
      &amp;lt;label&amp;gt;&amp;lt;/label&amp;gt;
      &amp;lt;choice value="setfirst"&amp;gt;Set First Token&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="unsetfirst"&amp;gt;Unset First Token&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="setsecond"&amp;gt;Set Second Token&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="unsetsecond"&amp;gt;Unset Second Token&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="setboth"&amp;gt;Set Both Tokens&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="unsetboth"&amp;gt;Unset Both Tokens&amp;lt;/choice&amp;gt;
      &amp;lt;change&amp;gt;
        &amp;lt;condition value="setfirst"&amp;gt;
          &amp;lt;set token="first"&amp;gt;true&amp;lt;/set&amp;gt;
        &amp;lt;/condition&amp;gt;
        &amp;lt;condition value="unsetfirst"&amp;gt;
          &amp;lt;unset token="first"&amp;gt;&amp;lt;/unset&amp;gt;
        &amp;lt;/condition&amp;gt;
        &amp;lt;condition value="setsecond"&amp;gt;
          &amp;lt;set token="second"&amp;gt;true&amp;lt;/set&amp;gt;
        &amp;lt;/condition&amp;gt;
        &amp;lt;condition value="unsetsecond"&amp;gt;
          &amp;lt;unset token="second"&amp;gt;&amp;lt;/unset&amp;gt;
        &amp;lt;/condition&amp;gt;
        &amp;lt;condition value="setboth"&amp;gt;
          &amp;lt;set token="first"&amp;gt;true&amp;lt;/set&amp;gt;
          &amp;lt;set token="second"&amp;gt;true&amp;lt;/set&amp;gt;
        &amp;lt;/condition&amp;gt;
        &amp;lt;condition value="unsetboth"&amp;gt;
          &amp;lt;unset token="first"&amp;gt;&amp;lt;/unset&amp;gt;
          &amp;lt;unset token="second"&amp;gt;&amp;lt;/unset&amp;gt;
        &amp;lt;/condition&amp;gt;
      &amp;lt;/change&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;Chart 1 (HTML section hides only when both first: $first$ and second: $second$ tokens are set)&amp;lt;/title&amp;gt;
      &amp;lt;html id="html1"&amp;gt;
        &amp;lt;div style="color:red;text-align:center;font-weight:bold;font-size:200%"&amp;gt;token1: $first$ - token2: $second$&amp;lt;/div&amp;gt;  
      &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Aug 2017 19:34:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-hide-HTML-in-panel-when-multiple-tokens-are-set/m-p/307452#M19593</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-08-28T19:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to hide HTML in panel when multiple tokens are set?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-hide-HTML-in-panel-when-multiple-tokens-are-set/m-p/307453#M19594</link>
      <description>&lt;P&gt;thank you! &lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2017 07:11:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-hide-HTML-in-panel-when-multiple-tokens-are-set/m-p/307453#M19594</guid>
      <dc:creator>avivn</dc:creator>
      <dc:date>2017-08-30T07:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to hide HTML in panel when multiple tokens are set?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-hide-HTML-in-panel-when-multiple-tokens-are-set/m-p/307454#M19595</link>
      <description>&lt;P&gt;Anytime &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2017 07:14:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-hide-HTML-in-panel-when-multiple-tokens-are-set/m-p/307454#M19595</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-08-30T07:14:28Z</dc:date>
    </item>
  </channel>
</rss>

