All Apps and Add-ons

How to get selected values from pulldown module?

sinnixx
Explorer

Hey,

I have a pulldown module wich is filled with search results.

        < module name="Pulldown">
          < param name="name">filiale</param>
          < param name="label">Filiale</param>
          < param name="size">7</param>
          < param name="template">location="*$value$"</param>
          < param name="separator">+OR+</param>
          < param name="outerTemplate">( $value$ )</param>
          < param name="staticOptions"></param>
          < param name="valueField">location</param>

...

If the pulldown items has been selected with the mouse the field $filiale$ looks correct:

( location="*50425" OR location="*59935" OR location="*80668" OR location="*80692" )

The problem:

After the user clicked a button, a javascript function marks some elements as selected (changes the "selected" property to true).

In this case the field value doesn´t change.

In the sideview utils sourcecode (/sideview_utils/modules/Pulldown/Pulldown.js) I found a function called "templatized" which returns the field value with the selected pulldown elements. But this function is only called after the items has been selected with the mouse. So it seems that i need the onchange event of the pulldown module.

I´ve tried to fire the onchange event manually - without any results.

How can i get the pulldown values after selecting via javascript?

1 Solution

sideview
SplunkTrust
SplunkTrust

If you just need to prepopulate three values in the Pulldown, whenever those values are present, you dont need custom javascript to do that, and it's far better to stay away from this sort of thing in the Splunk UI.

Instead just have this ValueSetter upstream from your Pulldown, way up at the top of the view just downstream from the URLLoader.

<module name="ValueSetter">
  <param name="name">filiale</param>
  <param name="value">50425,59935,82500</param>
  <param name="delim">,</param>

That will create an array-valued key whose name matches the name of the Pulldown, and when that flows downstream to the Pulldown, the Pulldown will automatically preselect those values.

This use case is simple enough that you don't need to write custom Javascript to tinker with the page directly. For more details and examples of the ValueSetter module, look in the latest Sideview Utils version (2.4.10) under "Module Documentation > The ValueSetter modules > ValueSetter".

http://sideviewapps.com/apps/sideview-utils

View solution in original post

sideview
SplunkTrust
SplunkTrust

If you just need to prepopulate three values in the Pulldown, whenever those values are present, you dont need custom javascript to do that, and it's far better to stay away from this sort of thing in the Splunk UI.

Instead just have this ValueSetter upstream from your Pulldown, way up at the top of the view just downstream from the URLLoader.

<module name="ValueSetter">
  <param name="name">filiale</param>
  <param name="value">50425,59935,82500</param>
  <param name="delim">,</param>

That will create an array-valued key whose name matches the name of the Pulldown, and when that flows downstream to the Pulldown, the Pulldown will automatically preselect those values.

This use case is simple enough that you don't need to write custom Javascript to tinker with the page directly. For more details and examples of the ValueSetter module, look in the latest Sideview Utils version (2.4.10) under "Module Documentation > The ValueSetter modules > ValueSetter".

http://sideviewapps.com/apps/sideview-utils

sinnixx
Explorer

this was very helpful! thanks!:)

0 Karma

sinnixx
Explorer

In the views.xml of my app I´ve included a html module with this code snippet:

//Select Region Button

0 Karma

sideview
SplunkTrust
SplunkTrust

How are you modifying the module with your own Javascript? Please post the source code of that modification or else I'll be trying to help you blind.

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...

Customer success is front and center at .conf25

Hi Splunkers, If you are not able to be at .conf25 in person, you can still learn about all the latest news ...