I have requirement after submit I need to hide and show row's panel on the condition of dropdown. when day is selected then show panel 1 and when hour is selected then show panel 2. I have queries in panel so that I don't want execute it also by adding the token condition.
<fieldset submitButton="true" autoRun="false">
<input type="dropdown" token="timespan">
<label>Time Span</label>
<choice value="1h">Hour</choice>
<choice value="1d">Day</choice>
<initialValue>1d</initialValue>
<default>1d</default>
</input>
</fieldset>
<row depends=???> ----- --panel 1
<row depends=???> --------panel 2
How to set and unset token after submit and what should be depends condition in row/panel?
Just hiding the row with depends="$token$" will not prevent the query from running - you need to add the depends to the search too.
Have a look at this dashboard - it uses a dummy row to have a search that sets/clears a token (is_hour) depending on the result of the setting, which will run after the submit is clicked. It will then set the token is_hour (or clear it). The subsequent two rows can then use depends/rejects to show/hide and run/not run the search.
<form>
<label>test</label>
<fieldset submitButton="true">
<input type="dropdown" token="timespan">
<label>Time Span</label>
<choice value="1h">Hour</choice>
<choice value="1d">Day</choice>
<initialValue>1d</initialValue>
<default>1d</default>
</input>
</fieldset>
<row depends="$hidden$">
<panel>
<table>
<title>is_hour=$is_hour$</title>
<search>
<query>| makeresults
| eval Type=$timespan|s$
</query>
<earliest>-24h@h</earliest>
<latest>now</latest>
<sampleRatio>1</sampleRatio>
<done>
<eval token="is_hour">if($result.Type$="1h", "hour", null())</eval>
</done>
</search>
<option name="count">100</option>
<option name="dataOverlayMode">none</option>
<option name="drilldown">none</option>
<option name="percentagesRow">false</option>
<option name="rowNumbers">false</option>
<option name="totalsRow">false</option>
<option name="wrap">true</option>
</table>
</panel>
</row>
<row depends="$is_hour$">
<panel>
<table>
<title>Hour search</title>
<search depends="$is_hour$">
<query>| makeresults
| eval Type="ByHour"
</query>
<earliest>-24h@h</earliest>
<latest>now</latest>
<sampleRatio>1</sampleRatio>
</search>
<option name="count">100</option>
<option name="dataOverlayMode">none</option>
<option name="drilldown">none</option>
<option name="percentagesRow">false</option>
<option name="rowNumbers">false</option>
<option name="totalsRow">false</option>
<option name="wrap">true</option>
</table>
</panel>
</row>
<row rejects="$is_hour$">
<panel>
<table>
<title>Day search</title>
<search rejects="$is_hour$">
<query>| makeresults
| eval Type="ByDay"
</query>
<earliest>-24h@h</earliest>
<latest>now</latest>
<sampleRatio>1</sampleRatio>
</search>
<option name="count">100</option>
<option name="dataOverlayMode">none</option>
<option name="drilldown">none</option>
<option name="percentagesRow">false</option>
<option name="rowNumbers">false</option>
<option name="totalsRow">false</option>
<option name="wrap">true</option>
</table>
</panel>
</row>
</form>
yes, I am able to do by adding change handler . Below are the code snippet. But I need after submit. Is there any way ?
<change>
<condition label="Hour">
<set token="show_hour">y</set>
<unset token="show_day"></unset>
</condition>
<condition label="Day">
<set token="show_day">y</set>
<unset token="show_hour"></unset>
</condition>
</change>
Just hiding the row with depends="$token$" will not prevent the query from running - you need to add the depends to the search too.
Have a look at this dashboard - it uses a dummy row to have a search that sets/clears a token (is_hour) depending on the result of the setting, which will run after the submit is clicked. It will then set the token is_hour (or clear it). The subsequent two rows can then use depends/rejects to show/hide and run/not run the search.
<form>
<label>test</label>
<fieldset submitButton="true">
<input type="dropdown" token="timespan">
<label>Time Span</label>
<choice value="1h">Hour</choice>
<choice value="1d">Day</choice>
<initialValue>1d</initialValue>
<default>1d</default>
</input>
</fieldset>
<row depends="$hidden$">
<panel>
<table>
<title>is_hour=$is_hour$</title>
<search>
<query>| makeresults
| eval Type=$timespan|s$
</query>
<earliest>-24h@h</earliest>
<latest>now</latest>
<sampleRatio>1</sampleRatio>
<done>
<eval token="is_hour">if($result.Type$="1h", "hour", null())</eval>
</done>
</search>
<option name="count">100</option>
<option name="dataOverlayMode">none</option>
<option name="drilldown">none</option>
<option name="percentagesRow">false</option>
<option name="rowNumbers">false</option>
<option name="totalsRow">false</option>
<option name="wrap">true</option>
</table>
</panel>
</row>
<row depends="$is_hour$">
<panel>
<table>
<title>Hour search</title>
<search depends="$is_hour$">
<query>| makeresults
| eval Type="ByHour"
</query>
<earliest>-24h@h</earliest>
<latest>now</latest>
<sampleRatio>1</sampleRatio>
</search>
<option name="count">100</option>
<option name="dataOverlayMode">none</option>
<option name="drilldown">none</option>
<option name="percentagesRow">false</option>
<option name="rowNumbers">false</option>
<option name="totalsRow">false</option>
<option name="wrap">true</option>
</table>
</panel>
</row>
<row rejects="$is_hour$">
<panel>
<table>
<title>Day search</title>
<search rejects="$is_hour$">
<query>| makeresults
| eval Type="ByDay"
</query>
<earliest>-24h@h</earliest>
<latest>now</latest>
<sampleRatio>1</sampleRatio>
</search>
<option name="count">100</option>
<option name="dataOverlayMode">none</option>
<option name="drilldown">none</option>
<option name="percentagesRow">false</option>
<option name="rowNumbers">false</option>
<option name="totalsRow">false</option>
<option name="wrap">true</option>
</table>
</panel>
</row>
</form>
Add a change handler block to the input and set tokens there dependent on the selection made