Dashboards & Visualizations

How do I update choices of DropdownView?

bhawkins1
Communicator

The splunk web framework provides a dropdown view component which I populate with choices before rendering:

  var menu = new DropdownView({
    id:              "split_categories_" + idx,
    choices:         opts_to_choices(opts),
    default:         "Usage",
    showClearButton: false,
    el:              $(this)
  }).render();

The documentation:

http://docs.splunk.com/DocumentationStatic/WebFramework/1.0/compref_dropdown.html

Provides info about listening to on-change events, setting choices, and rendering, but doesn't mention anything about changing the choices that appear in the dropdown menu.

If you analyse the structure of the menu object after rendering, you can see that choices are stored inside the options child object. None of the following correctly updates the choices:

  • Setting menu.choices to a new value
  • Setting menu.choices to a new value and re-rendering
  • Setting menu.options.choices to a new value
  • Setting menu.options.choices to a new value and re-rendering

If you take a look at the views source (which I'm not even sure is relevant or not),

https://github.com/splunk/splunk-webframework/blob/master/server/static/splunkjs/compiled/views.js

You might be led to believe that:

  • Setting menu.el.innerHTML = "" might cause menu.render() to work again
  • Calling menu.setItems() on a new object might be the correct way to change choices

Neither of these works either.

So what's the correct way to re-render the view?

1 Solution

bhawkins1
Communicator

The 1.0 reference is outdated. If you manually change the reference URL from 1.0 to 1.2, you'll get the following updated reference:

http://docs.splunk.com/DocumentationStatic/WebFramework/1.2/compref_dropdown.html

Here, you can see that menu.settings.set("choices", []) is the correct way to change the choices in a dropdown view.

Sadly, the default google result finds web framework @ 1.0, and the 1.0 docs don't have any reference to the 1.2 docs.

View solution in original post

bhawkins1
Communicator

The 1.0 reference is outdated. If you manually change the reference URL from 1.0 to 1.2, you'll get the following updated reference:

http://docs.splunk.com/DocumentationStatic/WebFramework/1.2/compref_dropdown.html

Here, you can see that menu.settings.set("choices", []) is the correct way to change the choices in a dropdown view.

Sadly, the default google result finds web framework @ 1.0, and the 1.0 docs don't have any reference to the 1.2 docs.

Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...

Network to App: Observability Unlocked [May & June Series]

In today’s digital landscape, your environment is no longer confined to the data center. It spans complex ...

SPL2 Deep Dives, AppDynamics Integrations, SAML Made Simple and Much More on Splunk ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...