Dashboards & Visualizations

How to load dashboard panels based on dropdown values which should be dependent on submit button?

admin12345678
Path Finder

Hi,

I have a dashboard where I have a dropdown with three values A, B and C, now if I click on value A it should set panel A, and If I choose value B it should load panel B and same for C also. now that code I have developed but in the dashboard added a submit button and disabled searchwhenchange but still prior to click on submit button panels load automatically after choosing values from the dropdown.

I need help on the submit button it should load panels only after clinking on the submit button.

please find the code below which I have developed.

 

 

<form>
  <label>My Dashboard</label>
  <fieldset submitButton="true">
    <input type="dropdown" token="dropdown_token" searchWhenChanged="false">
      <label>dropdown_token</label>
      <default>A</default>
      <choice value="A">A</choice>
      <choice value="B">B</choice>
      <choice value="C">C</choice>
      <change>
        <condition match="'value'==&quot;A&quot;">
          <set token="panelA">true</set>
          <unset token="panelB">false</unset>
          <unset token="panelC">false</unset>
        </condition>
        <condition match="'value'==&quot;B&quot;">
          <unset token="panelA">true</unset>
          <set token="panelB">false</set>
          <unset token="panelC">false</unset>
        </condition>
        <condition match="'value'==&quot;C&quot;">
          <unset token="panelA">true</unset>
          <unset token="panelB">false</unset>
          <set token="panelC">false</set>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel depends="$panelA$">
      <table>
        <title>Panel A</title>
        <search>
          <query>index=a |table a b c</query>
        </search>
      </table>
    </panel>
    <panel depends="$panelB$">
      <table>
        <title>Panel B</title>
        <search>
          <query>index=a |table a b c</query>
        </search>
      </table>
    </panel>
    <panel depends="$panelC$">
      <table>
        <title>Panel C</title>
        <search>
          <query>index=a |table a b c</query>
        </search>
      </table>
    </panel>
  </row>
</form>

 

 

Labels (4)
0 Karma

Tom_Lundie
Contributor

In your example, the tokens referenced in the depends= attributes are changing regardless of the submit action. Without using any custom JS; the only way (that I know of) to trigger a token change upon submit, is to use a search.

Here is an example based on your original question that makes use of a | makeresults command which is executed upon submit.  

<form>
  <label>My Dashboard</label>
  <search>
    <query>| makeresults | eval panel="$panelToggle$" | fields panel</query>
    <done>
      <unset token="panelA"></unset>
      <unset token="panelB"></unset>
      <unset token="panelC"></unset>
    </done>
    <done>
      <condition match="$result.panel$==&quot;A&quot;">
        <set token="panelA"></set>
      </condition>
      <condition match="$result.panel$==&quot;B&quot;">
        <set token="panelB"></set>
      </condition>
      <condition match="$result.panel$==&quot;C&quot;">
        <set token="panelC"></set>
      </condition>
    </done>
  </search>
  <fieldset submitButton="true" autoRun="false">
    <input type="dropdown" token="panelToggle" searchWhenChanged="false">
      <label>dropdown_token</label>
      <choice value="A">A</choice>
      <choice value="B">B</choice>
      <choice value="C">C</choice>
    </input>
  </fieldset>
  <search>
    <query>| makeresults | eval panel="$panelToggle$"</query>
    <progress>
      <unset token="panelA"></unset>
      <unset token="panelB"></unset>
      <unset token="panelC"></unset>
    </progress>
    <done>
      <condition match="$results.panel$==&quot;A&quot;">
        <set token="panelA"></set>
      </condition>
      <condition match="$results.panel$==&quot;B&quot;">
        <set token="panelB"></set>
      </condition>
      <condition match="$results.panel$==&quot;C&quot;">
        <set token="panelC"></set>
      </condition>
    </done>
  </search>
  <row>
    <panel depends="$panelA$">
      <table>
        <title>Panel A</title>
        <search depends="$panelA$">
          <query>index=a |table a b c</query>
        </search>
      </table>
    </panel>
    <panel depends="$panelB$">
      <table>
        <title>Panel B</title>
        <search depends="$panelB$">
          <query>index=a |table a b c</query>
        </search>
      </table>
    </panel>
    <panel depends="$panelC$">
      <table>
        <title>Panel C</title>
        <search depends="$panelC$">
          <query>index=a |table a b c</query>
        </search>
      </table>
    </panel>
  </row>
</form>

 (Note the use of depends= for the searches to, to stop the searches from running unnecessarily). 

 

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

How to find the worst searches in your Splunk environment and how to fix them

Everyone knows Splunk is a powerful platform for running searches and doing data analytics. Your ...

Share Your Feedback: On Admin Config Service (ACS)!

Help Us Build a Better Admin Config Service Experience (ACS)   We Want Your Feedback on Admin Config Service ...