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.

Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...