I have a dashboard where the input fields are set to searchWhenChanged="false"
. This was working as expected until I added an evaluated token from the value of one of these fields. Now, when I change the value of the input field associated with the evaluated token, the results table search automatically runs. Any suggestions on how to stop this?
Here is the token evaluation:
var offset = new DropdownInput({
"id": "offset",
"choices": [
{"label": "GMT", "value": "0"},
{"label": "PDT", "value": "25200"}
],
"searchWhenChanged": false,
"initialValue": "0",
"selectFirstChoice": false,
"showClearButton": true,
"default": "0",
"value": "$form.offset$",
"el": $('#offset')
}, {tokens: true}).render();
offset.on('change', function(newValue) {
FormUtils.handleValueChange(offset);
});
offset.on("valueChange", function(e) {
if (e.value !== undefined) {
EventHandler.evalToken("timezone", "$label$", e.data);
}
});
I found another way to achieve this. Instead of using an EventHandler.evalToken(...)
, I just grab the dropdown elements text.() and use it to set the "timezone" token when the submit button is pressed.
submit.on("submit", function() {
var timezone = $('#offset').text().match(/\w+/)[0];
setToken('timezone', timezone);
...
submitTokens();
});
I found another way to achieve this. Instead of using an EventHandler.evalToken(...)
, I just grab the dropdown elements text.() and use it to set the "timezone" token when the submit button is pressed.
submit.on("submit", function() {
var timezone = $('#offset').text().match(/\w+/)[0];
setToken('timezone', timezone);
...
submitTokens();
});
Do you have a working SimpleXML solution?
https://answers.splunk.com/answers/742451/searchwhenchangedfalse-not-honored-1.html
Hey @matstap,
great that you found the solution by yourself. Also many thanks to you for telling others how to handle this situation, if they ever encounter it. (Posting their working solutions is what most users forget here.)
Do you have a submit button to run the search after all tokens are set?
You could try removing the onchange event, in this case
offset.on('change', function(newValue) {
FormUtils.handleValueChange(offset);
});