Dashboards & Visualizations

Populate dropdown2 based on the selection made on dropdown1

hmahendrakumar
Path Finder

My use case is something similar to this

dropdown1 select country

dropdown2 select city

I should populate dropdown2 in my form only after some selection is made on dropdown1.

I guess my example pretty much explains my use case.

The workaround I have right now is to have a single dropdown with values concatenated(ie country1.city1, country1.city2 ...) which isn't pleasant if I have too many items in the dropdown. From the above example if I have 20 countries and each have 15 cities then I would end up with a dropdown containing 300 options which isn't good user experience.

0 Karma
1 Solution

Brian_Osburn
Builder

I highly suggest you take a look at the UI-Examples application - they have a prime example dedicated to this subject.

That being said, here's a snippet of one of my advanced xml examples:

    <!--Set up DropDown with host list-->
<module name="SearchSelectLister" layoutPanel="mainSearchControls" autoRun="True">
    <param name="settingToCreate">series_setting</param>
    <param name="search">| metadata type=hosts </param>
    <param name="earliest">-90d@d</param>
    <param name="searchFieldsToDisplay">
        <list>
            <param name="value">host</param>
            <param name="label">host</param>
        </list>
    </param>
    <param name="label">Team Fortress 2 Game Server:  </param>
    <module name="ConvertToIntention">
        <param name="settingToConvert">series_setting</param>
        <param name="intention">
            <param name="name">stringreplace</param>
            <param name="arg">
                <param name="host">
                    <param name="fillOnEmpty">True</param>
                    <param name="value">$target$</param>
                </param>
            </param>
        </param>

        <!--Set up DropDown with user list for specified host-->
        <module name="SearchSelectLister">
            <param name="settingToCreate">series_setting</param>
            <param name="applyOuterIntentionsToInternalSearch">True</param>
            <param name="searchWhenChanged">True</param>
            <param name="search">host="$host$" eventtype="tf2_login" | fields playername,host | dedup playername | sort playername </param>
            <param name="earliest">-90d@d</param>
            <param name="searchFieldsToDisplay">
                <list>
                    <param name="value">playername</param>
                    <param name="label">playername</param>
                </list>
            </param>
            <param name="label">Team Fortress 2 Player:   </param>
            <module name="ConvertToIntention">
                <param name="settingToConvert">series_setting</param>
                <param name="intention">
                    <param name="name">stringreplace</param>
                    <param name="arg">
                        <param name="playername">
                            <param name="fillOnEmpty">True</param>
                            <param name="value">$target$</param>
                        </param>
                    </param>
                </param>

I recommend you checking out http://www.splunk.com/base/Documentation/latest/Developer/UseSwitchers as well.

View solution in original post

hmahendrakumar
Path Finder

For the first, dropdown1, i use a search to populate it ...I have a search for dropdown1 which gets the selection on dropdown1 as parameter

0 Karma

Brian_Osburn
Builder

I highly suggest you take a look at the UI-Examples application - they have a prime example dedicated to this subject.

That being said, here's a snippet of one of my advanced xml examples:

    <!--Set up DropDown with host list-->
<module name="SearchSelectLister" layoutPanel="mainSearchControls" autoRun="True">
    <param name="settingToCreate">series_setting</param>
    <param name="search">| metadata type=hosts </param>
    <param name="earliest">-90d@d</param>
    <param name="searchFieldsToDisplay">
        <list>
            <param name="value">host</param>
            <param name="label">host</param>
        </list>
    </param>
    <param name="label">Team Fortress 2 Game Server:  </param>
    <module name="ConvertToIntention">
        <param name="settingToConvert">series_setting</param>
        <param name="intention">
            <param name="name">stringreplace</param>
            <param name="arg">
                <param name="host">
                    <param name="fillOnEmpty">True</param>
                    <param name="value">$target$</param>
                </param>
            </param>
        </param>

        <!--Set up DropDown with user list for specified host-->
        <module name="SearchSelectLister">
            <param name="settingToCreate">series_setting</param>
            <param name="applyOuterIntentionsToInternalSearch">True</param>
            <param name="searchWhenChanged">True</param>
            <param name="search">host="$host$" eventtype="tf2_login" | fields playername,host | dedup playername | sort playername </param>
            <param name="earliest">-90d@d</param>
            <param name="searchFieldsToDisplay">
                <list>
                    <param name="value">playername</param>
                    <param name="label">playername</param>
                </list>
            </param>
            <param name="label">Team Fortress 2 Player:   </param>
            <module name="ConvertToIntention">
                <param name="settingToConvert">series_setting</param>
                <param name="intention">
                    <param name="name">stringreplace</param>
                    <param name="arg">
                        <param name="playername">
                            <param name="fillOnEmpty">True</param>
                            <param name="value">$target$</param>
                        </param>
                    </param>
                </param>

I recommend you checking out http://www.splunk.com/base/Documentation/latest/Developer/UseSwitchers as well.

ericrobinson
Path Finder

Hi Brian, Which section in the UI app is the "prime example dedicated"? I cant seem to find it anywhere.. Thanks in advance.

0 Karma

hmahendrakumar
Path Finder

Thanks Brain... It works...

0 Karma

ziegfried
Influencer

Where do you get the options for the dropdowns? Are those gathered by a search or are they defined statically?

0 Karma
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...