Splunk Search

How to update search bar value when a drop-down value changes?

kevshah
Explorer

I am using following code to display search bar controls on a dashboard. I want to pass a query dynamically into a search bar based on drop-down values selection. (i.e. query in search bar should change whenever drop-down value changes)

 var mysearchbar = new SearchbarView ({
            id: "searchbar1",
            "value": sourcetype.value,
            el: $("#mysearchbar1")
        }, {tokens: true }).render();
0 Karma
1 Solution

sundareshr
Legend

You change change the search property. Here is an example to give an idea

mydropdown.on("change", function(newValue) {
    FormUtils.handleValueChange(mydropdown);
    // build you search string using values from dropdown
    var newsearchstring = "<<your new search string with value from dropdown>>
   mysearchbar.settings.set("value", newsearchstring)
                });

http://docs.splunk.com/Documentation/WebFramework

View solution in original post

sundareshr
Legend

You change change the search property. Here is an example to give an idea

mydropdown.on("change", function(newValue) {
    FormUtils.handleValueChange(mydropdown);
    // build you search string using values from dropdown
    var newsearchstring = "<<your new search string with value from dropdown>>
   mysearchbar.settings.set("value", newsearchstring)
                });

http://docs.splunk.com/Documentation/WebFramework

Get Updates on the Splunk Community!

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...