Dashboards & Visualizations

Use a CSS button to hide splunk panels

architkhanna
Path Finder

I have a button on a panel X of a dashboard which clears filters/tokens on all other panels (A,B,C) in same dashboard.
I want to use the same button to hide panels(A,B,C) all together and visible once I click on any value of the same panel(X)

Any help would be appreciated.

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@architkhanna

Can you please try this?

<dashboard script="myJS.js">
  <label>Click Button</label>
  <row>
    <panel>
      <title>X</title>
      <html>
        <input id="btn" type="button" value="Hide"/>
      </html>
    </panel>
  </row>
  <row>
    <panel depends="$tknA$">
      <table>
        <title>A</title>
        <search>
          <query>| stats count</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
    <panel depends="$tknB$">
      <table>
        <title>B</title>
        <search>
          <query>| stats count</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
    <panel depends="$tknC$">
      <table>
        <title>C</title>
        <search>
          <query>| stats count</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
</dashboard>

myJS.js

require([
        "splunkjs/mvc",
        "splunkjs/mvc/simplexml/ready!"
    ], function (
        mvc) {
    var defaultTokenModel = mvc.Components.get("default");
    var submittedTokenModel = mvc.Components.get("submitted");
    var flag=true;

    $("#btn").on("click", function () {
         console.log("lllllllll");
        if(flag)
        {
            defaultTokenModel.set("tknA", "Hi");
            defaultTokenModel.set("tknB", "Hi");
            defaultTokenModel.set("tknC", "Hi");
            submittedTokenModel.set("tknA", "Hi");
            submittedTokenModel.set("tknB", "Hi");
            submittedTokenModel.set("tknC", "Hi");
            flag = false;
        }
        else {
            defaultTokenModel.unset("tknA");
            defaultTokenModel.unset("tknB");
            defaultTokenModel.unset("tknC");
            submittedTokenModel.unset("tknA");
            submittedTokenModel.unset("tknB");
            submittedTokenModel.unset("tknC");

            flag = true;
        }
        submittedTokenModel.set(defaultTokenModel.toJSON());
        return false;
    });

});
Get Updates on the Splunk Community!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...