<?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: Splunk 6.1.5: How to get the default selection from a multiselect drop-down cleared when someone selects another of the populated options in simple XML? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-1-5-How-to-get-the-default-selection-from-a-multiselect/m-p/140910#M8483</link>
    <description>&lt;P&gt;I believe this is a good solution, though it is in JS and not in XML, so you'll have to modify your app code accordingly. In case this is relevant, this was only tested in Splunk 6.2.2.&lt;/P&gt;

&lt;P&gt;Listening on a change on the multiselect, we can identify the number of selected items and whether one of the options is &lt;CODE&gt;"*"&lt;/CODE&gt; (or whatever your "all" option results in). If this is the case, in the second if-clause we check whether the &lt;CODE&gt;"*"&lt;/CODE&gt; was there first and the user just selected a more specific option or whether some options were selected and the user chose the "any" option. For the former case, we remove the &lt;CODE&gt;"*"&lt;/CODE&gt; and leave the other options, and for the latter we simply replace the selection with &lt;CODE&gt;"*"&lt;/CODE&gt;. This behavior is based on the assumption that when you select the "any" option, this overrides the more specific options that were already selected. You can of course adjust this behavior to your needs.&lt;/P&gt;

&lt;P&gt;Here is a small code example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var selection = [];
var multi = splunkjs.mvc.Components.getInstance("input1"); // your multiselect id here

multi.on("change", function(){
    // get the current selection
    selection = multi.val();
    // check if there is more than one entry and one of them is "*"
    if (selection.length &amp;gt; 1 &amp;amp;&amp;amp; ~(selection.indexOf("*"))) {
        if (selection.indexOf("*") == 0) {
            // "*" was first, remove it and leave rest
            selection.splice(selection.indexOf("*"), 1);
            multi.val(selection);
            multi.render();
        } else {
            // "*" was added later, remove rest and leave "*"
            multi.val("*");
            multi.render();
        }
    }
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Cheers&lt;/P&gt;</description>
    <pubDate>Tue, 24 Mar 2015 09:41:32 GMT</pubDate>
    <dc:creator>jeffland</dc:creator>
    <dc:date>2015-03-24T09:41:32Z</dc:date>
    <item>
      <title>Splunk 6.1.5: How to get the default selection from a multiselect drop-down cleared when someone selects another of the populated options in simple XML?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-1-5-How-to-get-the-default-selection-from-a-multiselect/m-p/140908#M8481</link>
      <description>&lt;P&gt;Has anyone found a way to get the default selection from a multiselect cleared when someone selects another of the populated options.&lt;/P&gt;

&lt;P&gt;Example :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;label&amp;gt;Node&amp;lt;/label&amp;gt;
&amp;lt;populatingSearch earliest="-5m" latest="now" fieldForLabel="host" fieldForValue="host"&amp;gt;index=blah&amp;lt;/populatingSearch&amp;gt;
&amp;lt;choice value="*"&amp;gt;All&amp;lt;/choice&amp;gt;
&amp;lt;default&amp;gt;*&amp;lt;/default&amp;gt;
&amp;lt;delimiter&amp;gt; OR &amp;lt;/delimiter&amp;gt;
&amp;lt;valuePrefix&amp;gt;host=&amp;lt;/valuePrefix&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This drop down will populate a list of recent hosts so a user can narrow their search. A default of "all" (or "*") allow them to just click submit without knowing a specific host. They can later select a specific host of interest. &lt;/P&gt;

&lt;P&gt;The problem is that if they do select another host (by typing a name or selecting it from the drop down) they will need to manually remove the All option. If they don't then the search will show them everything (i'm using an OR delim so they can multiselect hosts).&lt;/P&gt;</description>
      <pubDate>Mon, 01 Dec 2014 05:09:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-1-5-How-to-get-the-default-selection-from-a-multiselect/m-p/140908#M8481</guid>
      <dc:creator>Lucas_K</dc:creator>
      <dc:date>2014-12-01T05:09:23Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk 6.1.5: How to get the default selection from a multiselect drop-down cleared when someone selects another of the populated options in simple XML?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-1-5-How-to-get-the-default-selection-from-a-multiselect/m-p/140909#M8482</link>
      <description>&lt;P&gt;I have exactly the same issue. Any chance you figured out a solution?&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2015 13:03:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-1-5-How-to-get-the-default-selection-from-a-multiselect/m-p/140909#M8482</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2015-03-23T13:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk 6.1.5: How to get the default selection from a multiselect drop-down cleared when someone selects another of the populated options in simple XML?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-1-5-How-to-get-the-default-selection-from-a-multiselect/m-p/140910#M8483</link>
      <description>&lt;P&gt;I believe this is a good solution, though it is in JS and not in XML, so you'll have to modify your app code accordingly. In case this is relevant, this was only tested in Splunk 6.2.2.&lt;/P&gt;

&lt;P&gt;Listening on a change on the multiselect, we can identify the number of selected items and whether one of the options is &lt;CODE&gt;"*"&lt;/CODE&gt; (or whatever your "all" option results in). If this is the case, in the second if-clause we check whether the &lt;CODE&gt;"*"&lt;/CODE&gt; was there first and the user just selected a more specific option or whether some options were selected and the user chose the "any" option. For the former case, we remove the &lt;CODE&gt;"*"&lt;/CODE&gt; and leave the other options, and for the latter we simply replace the selection with &lt;CODE&gt;"*"&lt;/CODE&gt;. This behavior is based on the assumption that when you select the "any" option, this overrides the more specific options that were already selected. You can of course adjust this behavior to your needs.&lt;/P&gt;

&lt;P&gt;Here is a small code example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var selection = [];
var multi = splunkjs.mvc.Components.getInstance("input1"); // your multiselect id here

multi.on("change", function(){
    // get the current selection
    selection = multi.val();
    // check if there is more than one entry and one of them is "*"
    if (selection.length &amp;gt; 1 &amp;amp;&amp;amp; ~(selection.indexOf("*"))) {
        if (selection.indexOf("*") == 0) {
            // "*" was first, remove it and leave rest
            selection.splice(selection.indexOf("*"), 1);
            multi.val(selection);
            multi.render();
        } else {
            // "*" was added later, remove rest and leave "*"
            multi.val("*");
            multi.render();
        }
    }
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2015 09:41:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-1-5-How-to-get-the-default-selection-from-a-multiselect/m-p/140910#M8483</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2015-03-24T09:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk 6.1.5: How to get the default selection from a multiselect drop-down cleared when someone selects another of the populated options in simple XML?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-1-5-How-to-get-the-default-selection-from-a-multiselect/m-p/140911#M8484</link>
      <description>&lt;P&gt;Hello, &lt;/P&gt;

&lt;P&gt;i would like to have multiple default value . Is it possible ?&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2016 12:52:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-1-5-How-to-get-the-default-selection-from-a-multiselect/m-p/140911#M8484</guid>
      <dc:creator>jeandez</dc:creator>
      <dc:date>2016-05-12T12:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk 6.1.5: How to get the default selection from a multiselect drop-down cleared when someone selects another of the populated options in simple XML?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-1-5-How-to-get-the-default-selection-from-a-multiselect/m-p/140912#M8485</link>
      <description>&lt;P&gt;"input1" is the token value from the multiselect or Lable name ?&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2016 00:20:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-1-5-How-to-get-the-default-selection-from-a-multiselect/m-p/140912#M8485</guid>
      <dc:creator>sivapuvvada</dc:creator>
      <dc:date>2016-05-13T00:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk 6.1.5: How to get the default selection from a multiselect drop-down cleared when someone selects another of the populated options in simple XML?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-1-5-How-to-get-the-default-selection-from-a-multiselect/m-p/140913#M8486</link>
      <description>&lt;P&gt;&lt;CODE&gt;"input1"&lt;/CODE&gt; is the id of the input.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2017 08:52:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-1-5-How-to-get-the-default-selection-from-a-multiselect/m-p/140913#M8486</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2017-01-11T08:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk 6.1.5: How to get the default selection from a multiselect drop-down cleared when someone selects another of the populated options in simple XML?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-1-5-How-to-get-the-default-selection-from-a-multiselect/m-p/140914#M8487</link>
      <description>&lt;P&gt;Mild extension: Add this to the outer if to get the default value back after deleting all entries from the list:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;} else if (selection.length == 0) {
    // "*" should be inserted if the list is empty
    multi.val("*");
    multi.render();
}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Jan 2017 08:53:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-1-5-How-to-get-the-default-selection-from-a-multiselect/m-p/140914#M8487</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2017-01-11T08:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk 6.1.5: How to get the default selection from a multiselect drop-down cleared when someone selects another of the populated options in simple XML?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-1-5-How-to-get-the-default-selection-from-a-multiselect/m-p/140915#M8488</link>
      <description>&lt;P&gt;@martin_mueller  how to check for dispaly label instead of  value"*".&lt;BR /&gt;
my multiselect is not a * value so i want to look for a specific label value "ALL Shops"&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2020 13:47:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-1-5-How-to-get-the-default-selection-from-a-multiselect/m-p/140915#M8488</guid>
      <dc:creator>DataOrg</dc:creator>
      <dc:date>2020-01-28T13:47:14Z</dc:date>
    </item>
  </channel>
</rss>

