Dashboards & Visualizations

How to make multiple panels to disappear/appear when changes to radio button happen?

thisemailwillbe
Explorer

So basically what I'm trying to do it that I want a radio button at the top of the page and depending on one of the four choices of sais radio button, make a whole swath of panels to appear/disappear. I'm having troubles trying to figure out how to use the tokens to achieve this. Thanks in advance for any help! (I should also mention that I'm running 7.2.5)

0 Karma
1 Solution

manjunathmeti
Champion

hi @thisemailwillbeusedfortesting,

Try this:

<form hideSplunkBar="true">
  <label>Choose filters</label>
  <fieldset submitButton="false">
    <input type="radio" token="checkbox">
      <label>Checkbox</label>
      <choice value="checkbox1">Show Panel 1</choice>
      <choice value="checkbox2">Show Panel 2</choice>
      <choice value="checkbox3">Show Panel 3</choice>
      <choice value="checkbox4">Show Panel 4</choice>
      <change>
        <condition value="checkbox1">
          <set token="flag1">true</set>
          <unset token="flag2"></unset>
          <unset token="flag3"></unset>
          <unset token="flag4"></unset>
        </condition>
        <condition value="checkbox2">
          <set token="flag2">true</set>
          <unset token="flag1"></unset>
          <unset token="flag3"></unset>
          <unset token="flag4"></unset>
        </condition>
        <condition value="checkbox3">
          <set token="flag3">true</set>
          <unset token="flag1"></unset>
          <unset token="flag2"></unset>
          <unset token="flag4"></unset>
        </condition>
        <condition value="checkbox4">
          <set token="flag4">true</set>
          <unset token="flag1"></unset>
          <unset token="flag2"></unset>
          <unset token="flag3"></unset>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel depends="$flag1$">
      <title>Panel 1</title>
      <table>
        <title>Count by sourcetype</title>
        <search>
          <query>index=_internal earliest=-5m | stats count by sourcetype</query>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
      </table>
    </panel>
    <panel depends="$flag2$">
      <title>Panel 2</title>
      <table>
        <title>Count by source</title>
        <search>
          <query>index=_internal earliest=-5m | stats count by source</query>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
      </table>
    </panel>
    <panel depends="$flag3$">
      <title>Panel 3</title>
      <table>
        <title>Count by host</title>
        <search>
          <query>index=_internal earliest=-5m | stats count by host</query>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
      </table>
    </panel>
    <panel depends="$flag4$">
      <title>Panel 4</title>
      <table>
        <title>Count by splunk server</title>
        <search>
          <query>index=_internal earliest=-5m | stats count by splunk_server</query>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
</form>

View solution in original post

manjunathmeti
Champion

hi @thisemailwillbeusedfortesting,

Try this:

<form hideSplunkBar="true">
  <label>Choose filters</label>
  <fieldset submitButton="false">
    <input type="radio" token="checkbox">
      <label>Checkbox</label>
      <choice value="checkbox1">Show Panel 1</choice>
      <choice value="checkbox2">Show Panel 2</choice>
      <choice value="checkbox3">Show Panel 3</choice>
      <choice value="checkbox4">Show Panel 4</choice>
      <change>
        <condition value="checkbox1">
          <set token="flag1">true</set>
          <unset token="flag2"></unset>
          <unset token="flag3"></unset>
          <unset token="flag4"></unset>
        </condition>
        <condition value="checkbox2">
          <set token="flag2">true</set>
          <unset token="flag1"></unset>
          <unset token="flag3"></unset>
          <unset token="flag4"></unset>
        </condition>
        <condition value="checkbox3">
          <set token="flag3">true</set>
          <unset token="flag1"></unset>
          <unset token="flag2"></unset>
          <unset token="flag4"></unset>
        </condition>
        <condition value="checkbox4">
          <set token="flag4">true</set>
          <unset token="flag1"></unset>
          <unset token="flag2"></unset>
          <unset token="flag3"></unset>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel depends="$flag1$">
      <title>Panel 1</title>
      <table>
        <title>Count by sourcetype</title>
        <search>
          <query>index=_internal earliest=-5m | stats count by sourcetype</query>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
      </table>
    </panel>
    <panel depends="$flag2$">
      <title>Panel 2</title>
      <table>
        <title>Count by source</title>
        <search>
          <query>index=_internal earliest=-5m | stats count by source</query>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
      </table>
    </panel>
    <panel depends="$flag3$">
      <title>Panel 3</title>
      <table>
        <title>Count by host</title>
        <search>
          <query>index=_internal earliest=-5m | stats count by host</query>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
      </table>
    </panel>
    <panel depends="$flag4$">
      <title>Panel 4</title>
      <table>
        <title>Count by splunk server</title>
        <search>
          <query>index=_internal earliest=-5m | stats count by splunk_server</query>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
</form>

thisemailwillbe
Explorer

Thank you! This is exactly what I needed. Cheers!

0 Karma

manjunathmeti
Champion

You're welcome 🙂

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...