Dashboards & Visualizations

Remove "All" from multiselect input when other options selected vice versa

DataOrg
Builder

i have multiple multi-select input in dashboard but i want to apply on the particular multiselect without disturbing other inputs.
if all is selected i want to remove other values from the selection vice versa

0 Karma

poete
Builder

Hello @premranjithj .

You can achieve this using the following steps:

<input type="multiselect" token="object_type_token" id="object_type">
  <label>Subcategory</label>
  <choice value="*">All</choice>
  <valuePrefix>subcategory="</valuePrefix>
  <valueSuffix>"</valueSuffix>
  <delimiter> OR </delimiter>
  <fieldForLabel>subcategory</fieldForLabel>
  <fieldForValue>subcategory</fieldForValue>
  <search>
    <query>...</query>
    <earliest>-24h@h</earliest>
    <latest>now</latest>
  </search>
</input>

Here you set the id of the multiselect, and the valuePrefix

Then, you need to associate the right behaviour with the javascript.

Here is an example, to handle a toggle when 'All' is selected:

// Handle the "All" attribut of every inputs
var defaultTokenModel = mvc.Components.get("default");

    // On "TypeObjet" change :
defaultTokenModel.on("change:object_type_token", function(new_object_type_token, object_type_token, options) {
    if (object_type_token!=null){
    // Handle the "All" value, in case "All" is selected, and another value is added. In this case, "All" is removed
        if (object_type_token.startsWith("subcategory=\"*\" OR ")){
            var withoutAll = object_type_token.replace("subcategory=\"*\" OR ","");
            withoutAll = withoutAll.replace("subcategory=\"","");
            withoutAll = withoutAll.replace("\"","");
            defaultTokenModel.set("form.object_type_token", withoutAll);
        }
        // Handle the "All" value, in case it is added to the multiselect. In this case, keep only "All"
        if (object_type_token.endsWith(" OR subcategory=\"*\"")) {
                defaultTokenModel.set("form.object_type_token", "*");
        }
});

This is a proposal, in order to provide an example of implementation.

I hope this helps!

0 Karma

DataOrg
Builder

@poete . this is not working on the mutiselect

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...