Hi guys
I have three form inputs. The last two are dynamic dropdowns. Their values are generated with a search, in which the value from the first input is used. The dropdowns are configured to always select the first choice
<selectFirstChoice>true</selectFirstChoice>
Whenever I change the first input, the two other dynamic dropdowns are regenerated. Unfortunately the dropdown's selected choice goes empty, instead of choosing the first available value.
Has someone else experienced the same? Or can someone provide me with a workaround?
Thank you
You can set this for the dropdown:
<change>
<unset token="form.dropdown"></unset>
</change>
example dashboard
<form script="simple_xml_examples:showtokens.js">
<label>selectfirstchoice</label>
<fieldset submitButton="false" autoRun="true">
<input type="dropdown" token="dropdown" searchWhenChanged="true">
<!--<choice value="foo">Foo</choice>-->
<search>
<query>index=$index$ | head 200 | stats count by sourcetype</query>
</search>
<fieldForLabel>sourcetype</fieldForLabel>
<fieldForValue>sourcetype</fieldForValue>
<selectFirstChoice>true</selectFirstChoice>
</input>
<input type="text" token="index" searchWhenChanged="true">
<change>
<unset token="form.dropdown"></unset>
</change>
</input>
<input type="time" token="field1" searchWhenChanged="true">
<label></label>
<default>
<earliest>-15m</earliest>
<latest>now</latest>
</default>
</input>
</fieldset>
<row>
<panel>
<chart>
<search>
<query>index=_internal | timechart count</query>
<earliest>$field1.earliest$</earliest>
<latest>$field1.latest$</latest>
</search>
<option name="charting.chart">line</option>
</chart>
</panel>
</row>
</form>
You can set this for the dropdown:
<change>
<unset token="form.dropdown"></unset>
</change>
example dashboard
<form script="simple_xml_examples:showtokens.js">
<label>selectfirstchoice</label>
<fieldset submitButton="false" autoRun="true">
<input type="dropdown" token="dropdown" searchWhenChanged="true">
<!--<choice value="foo">Foo</choice>-->
<search>
<query>index=$index$ | head 200 | stats count by sourcetype</query>
</search>
<fieldForLabel>sourcetype</fieldForLabel>
<fieldForValue>sourcetype</fieldForValue>
<selectFirstChoice>true</selectFirstChoice>
</input>
<input type="text" token="index" searchWhenChanged="true">
<change>
<unset token="form.dropdown"></unset>
</change>
</input>
<input type="time" token="field1" searchWhenChanged="true">
<label></label>
<default>
<earliest>-15m</earliest>
<latest>now</latest>
</default>
</input>
</fieldset>
<row>
<panel>
<chart>
<search>
<query>index=_internal | timechart count</query>
<earliest>$field1.earliest$</earliest>
<latest>$field1.latest$</latest>
</search>
<option name="charting.chart">line</option>
</chart>
</panel>
</row>
</form>
I have a similar scenario with two dropdowns. This solution mostly worked for me. The only issue is that when I first navigate to the page, the second dropdown is empty until the user either: A) Refreshes the page, or B) Changes the first dropdown's selection.
For clarity, this only seems to happen the first time I navigate to my dashboard either from the dashboard selection or after saving edits to the simpleXML.
I believe the issue is that the second dropdown is being populated and then the first dropdown is calling the tag and leaving the second dropdown unpopulated until the user changes the first dropdown again. It's worth noting that I've tried setting selectFirstChoice to true for both, and true for just the second dropdown.
Has anyone else experienced something similar that would be able to offer up a solution/advice?
Thank you, Kind Sir. This turned out to be trickier than I expected.
Works beautifully !! Is there any way that the dropdown value can be reset to its default value?
This worked for me although I was confused at first by the ordering but it's that the dropdown gets auto-reset and reselected each time index is changed.
This worked like a charm. Thanks!
I guess that works just on the first load of the dashboard. If the underlying data source for the dropdown is changed some how, it's ignoring the updated first value.
Please try this workaround http://answers.splunk.com/answers/247982/how-to-have-dynamic-form-inputsprompts-reset-their-1.html
Converting to HTML is no option for us. Our users then would not be possible to make any further changes to the dashboard. I am sorry, but that is no solution for us.
I see the same issue. When I update a dropdown menu, the ones that depend on it and use the selectFirstChoice flag will update their contents, but not change the actual parameter.
E.g.,
Menu contains {0,5,10}, selects '0'. After updating another menu, it now contains {5, 10, 15}, but still sits on '0'.
This makes the feature somewhat useless.