Dashboards & Visualizations

Dashboard with dynamic multi-select searchWhenChanged=false

big_nuggets
Explorer

I have a multiselect input that gets populated by results from a search. When I set searchwhenchanged="false" it it doesn't add the selectedValue to the multiselect.

This is some broken code that I spaghettied together from searching, clearly I'm not great with Splunk:

 

 

require(['splunkjs/mvc', 'splunkjs/mvc/simplexml/ready!'], function (mvc) {

    console.log("multiselect_functions.js loaded.");

    function setupMultiInput(instance_id) {
        /*
         */

        // Get multiselect  
        //    var multi = mvc.Components.get(instance_id);

        // On change, check selection  
        //    multi.on("change", (selectedValues) => {
        //        console.log("values:  " + selectedValues);

        //    });

        var multi = mvc.Components.get(instance_id);

        // On change, check selection  
        multi.on("change", function() {
            console.log("change " +multi.val());
            multi.settings.set.choices("choices", ['53','57']);
            //blah
        });

    }

    var all_multi_selects = document.getElementsByClassName("input-multiselect");
    for (j = 0; j < all_multi_selects.length; j++) {
        setupMultiInput(all_multi_selects[j].id);
    }

});

 

 

 Above I'm just trying to insert to some random stuff, I get a multi.settings.set.choices is not a function error, so I am probably trying on the wrong object. Any help would be greatly appreciated it, thank you.

Labels (5)
0 Karma
1 Solution

big_nuggets
Explorer

Doing this works:

 

multi.val(['AA','BB','CC']);

 

View solution in original post

0 Karma

big_nuggets
Explorer

Doing this works:

 

multi.val(['AA','BB','CC']);

 

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

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...

Customer success is front and center at .conf25

Hi Splunkers, If you are not able to be at .conf25 in person, you can still learn about all the latest news ...