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!

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 ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

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 ...