Archive

Dynamic value display in the Panel Title

Path Finder

Hi All,

I need to display dynamic value in the panel title. The dynamic value needs to come from the time range label.

I have a custom time picker whose partial code snippet is below...

<form>
<label>Demand Billed Dashboard-DBQuery Clone</label>
<fieldset submitButton="false" autoRun="true">
<input type="dropdown" token="field1" searchWhenChanged="true">
<label>Select Time Range</label>
<choice value="1">1 day ago</choice>
<choice value="2">2 days ago</choice>

<default>1</default>
</input>

</fieldset>
<row>
<panel>
<table>
<title>Demand Billed - $field1$</title>

In the title tag with the '$field1$' i am able to display the value [1 or 2 depending upon what is selected as time range].

How can we display the text "1 day ago" corresponding to value="1" , i want to get the text and display it based on the time range selection instead of the value.

Please guide me.

Requirement ---> title should be displayed as

Demand Billed - 1 day ago
Demand Billed - 2 days ago

Tags (2)
0 Karma
1 Solution

Communicator

we can achieve this using Javascript. where we can capture dropdown label and render it in token in panel header.

View solution in original post

Path Finder

This is now possible to do in SimpleXML.

Modify your input, and add a change action

<default>1</default>
      <change>
        <set token="display">$label$</set>
      </change>

The change your panel title to use the new token

<title>Demand Billed - $display$</title>

Path Finder

This worked for me with time pickers. It is not pretty while it waits for data to load but once it gets the field1 values it works.

Next I want to play with the time format.

0 Karma

Path Finder

$field1.earliest$ to $field1.latest$

0 Karma

Path Finder

So, I use that at the end of my title.

0 Karma

Communicator

we can achieve this using Javascript. where we can capture dropdown label and render it in token in panel header.

View solution in original post

Path Finder

thanks Nawneel!

0 Karma

Path Finder

Hi All,

Any other pointers as to how this can be achieved. Thanks.

0 Karma

Motivator

Hi nekbote

It is simple

form>
<label>Demand Billed Dashboard-DBQuery Clone</label>
<fieldset submitButton="false" autoRun="true">
 <input type="time" searchWhenChanged="true">
      <label>Select a time:</label>
      <default>Last 24 hours</default>
    </input>
</fieldset>
<row>
<panel>
<table>
<title>Demand Billed Demand Billed  there are  $earliest$</title>

You can also use the following

<title>Demand Billed Demand Billed  between $earliest$ and  $latest$</title>

where :
-1d@d represent 1 day ago
-2d@d represent 2 day ago

0 Karma

Path Finder

Hi Chimell,

Thanks for the suggestion but it does not work in my case.

Mine is custom time picker which provides 1-14 day time selection [earliest and latest alone does not work]. I want to display the the label corresponding to the time picker value. in your suggestion , i want to display the value 1 day ago as label and not -1d@d.

<form>
<label>Demand Billed Dashboard-DBQuery Clone</label>
<fieldset submitButton="false" autoRun="true">
<input type="dropdown" token="field1" searchWhenChanged="true">
<label>Select Time Range</label>
<choice value="1">1 day ago</choice>
<choice value="2">2 days ago</choice>
<choice value="3">3 days ago</choice>
<choice value="4">4 days ago</choice>
<choice value="5">5 days ago</choice>
<choice value="6">6 days ago</choice>
<choice value="7">7 days ago</choice>
<choice value="8">8 days ago</choice>
<choice value="9">9 days ago</choice>
<default>1</default>
</input>
</fieldset>
<row>
<panel>
<table>
<title>Demand Billed - $field1$</title>

0 Karma

Motivator

hi,
try like this

<form>
<label>Demand Billed Dashboard-DBQuery Clone</label>

<fieldset submitButton="false" autoRun="true">
<input type="dropdown" token="field1" searchWhenChanged="true">
<label>Select Time Range</label>
<choice value="1 day ago">1 day ago</choice>
<choice value="2 days ago">2 days ago</choice> 
<default>1 day ago</default>
</input> 
</fieldset>
<row>
<panel>
<table>
<title>Demand Billed - $field1$</title>

OR

 <form>
 <label>Demand Billed Dashboard-DBQuery Clone</label>

 <fieldset submitButton="false" autoRun="true">
 <input type="dropdown" token="field1" searchWhenChanged="true">
 <label>Select Time Range</label>
 <choice value="1 day ago"> 1 </choice>
 <choice value="2 days ago"> 2 </choice> 
 <default>1 day ago</default>
 </input> 
 </fieldset>
 <row>
 <panel>
 <table>
 <title>Demand Billed - $field1$</title>

because $field1$ don't take the label but take the value
please forgive my english.

0 Karma

Path Finder

Thanks gyslainlatsa for the information. But i dont think this solution works and the reason being in my search query i still need to use the token $field1$ and your suggested solution will not work.

My searc hquery makes use of the token in the below date condition.

VARCHAR_FORMAT(CURRENT TIMESTAMP - $field1$ day, 'YYYYMMDD')

Do you have any other suggestion of getting around it.

Also just an addition , yes i understand $field1$ takes value and not label and i am requesting how to get the label.

0 Karma
State of Splunk Careers

Access the Splunk Careers Report to see real data that shows how Splunk mastery increases your value and job satisfaction.

Find out what your skills are worth!