Dashboards & Visualizations

How to add autoRun=false, and only run a search when I click on a submit button in an HTML dashboard?

sfatnass
Contributor

i need to load my request only when i use a submit button.
so when i change input fields, the search should only run if i click the submit button.

but i don't know what i should to add on my HTML dashboard.

i can't use an XML dashboard and convert it because the dashboard exists and contains many elements.

1 Solution

sundareshr
Legend

Each control should have a onchange event. Try removing those. It is typically right after the control definition. And do a submitTokens()

var submit = new SubmitButton({
....
}, {tokens: true}).render();

submit.on("submit", function() {
   submitTokens();
});

View solution in original post

0 Karma

sundareshr
Legend

Each control should have a onchange event. Try removing those. It is typically right after the control definition. And do a submitTokens()

var submit = new SubmitButton({
....
}, {tokens: true}).render();

submit.on("submit", function() {
   submitTokens();
});
0 Karma

_jgpm_
Communicator

I have similar submitTokens but in my auto-generated HTML source I found this near the bottom of the file:
//
// VIEWS: FORM INPUTS
//

In here is how I changed it. I'm not sure what some of the inputs are as my dashboard has 5 inputs (4 dropdowns and 1 submit button) but the HTML code has 6 inputs. Here is an example of each type:

var input1 = new HtmlElement({
            "id": "input1",
            "useTokens": true,
            "el": $('#input1')
        }, {tokens: true, tokenNamespace: "submitted"}).render();

        DashboardController.addReadyDep(input1.contentLoaded());

        input1.on("change", function(newValue) {
            FormUtils.handleValueChange(input1);
        });

var input3 = new DropdownInput({
            "id": "input3",
            "choices": [],
            "selectFirstChoice": false,
            **"searchWhenChanged": false,**
            "labelField": "values(tag)",
            "showClearButton": true,
            "valueField": "values(tag)",
            "value": "$form.tag$",
            "managerid": "search8",
            "el": $('#input3')
        }, {tokens: true}).render();

        input3.on("change", function(newValue) {
            FormUtils.handleValueChange(input3);
        });

I found that if you have multiple inputs and if any of them have searchWhenChanged=true, then the whole thing kicks off.

0 Karma

sfatnass
Contributor

currently i have only submitTokens() like your description.

but the request start on loading page not after submit action.

0 Karma

sundareshr
Legend

Please share your dashboard code.

0 Karma
Get Updates on the Splunk Community!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...