416.467.9100 | Dundas Data Visualization | Login
Welcome Guest
This is the support page for the legacy Dundas Dashboard application. For assistance with the current Dundas BI application please click here.
Dashboard v5.0

This site makes extensive use of JavaScript.

Please enable JavaScript in your web browser and reload the page before proceeding.

Scripting a Parameter Filter - Drop Down List

Hide navigation
RSS
Modified on Tue, 02 Apr 2013 10:36 AM

This article describes how to use custom scripting to set the parameter filter value behind the Drop Down List control.

Overview

The Dundas Dashboard Parameter Drop Down List control lets users make a single selection from a list of string filter values.

Parameter Drop Down List control.

Parameter Drop Down List control.


Parameter structure

The Drop Down List parameter has one FilterValues object, which contains either
  • a range token (e.g. NamedToken.All to represent all values) or
  • one MemberValues object to represent the string or numeric filter value.

Getting current parameter values

Use the debug script found here to output the relevant parameter properties that need to be set via scripting.

The relevant properties are:

Script NameTypeDescription
DashboardParameter.FilterValuesCollection<DashboardFilterValueData>The filter values. Each item in the list contains details specific to a single selection.
DashboardParameter.FilterValues.NamedTokenValueNamedTokenThe named token value of the filter. A token represents an intelligent selection of values.
DashboardParameter.FilterValues.MemberValuesCollection<DashboardMemberValueData>The member values. Each item in the list contains details specific to a single element that comprises the selection.
DashboardParameter.FilterValues.MemberValues.ValuesCollection<object>The values. These are the key(s) used to uniquely identify an element in the dimension.
DashboardParameter.FilterValues.MemberValues.ReadableValuesCollection<string>The readable values. ReadableValues must always be set whenever Values is set. The purpose here is to provide a human-readable value to the script engine in case the user wishes to print out the values of this parameter.

Setting new parameter values

Use the following script to set a new filter value for the Drop Down List control.

/******************** USER VARIABLES ********************/ object param = ParameterDropDownList; // your parameter object newFilterValue = "Filter String"; // string, number, or token /********************************************************/

// Clear the existing filter param.FilterValues.Clear();

// Create a new filter object DashboardFilterValueData fvd = new DashboardFilterValueData();

if (newFilterValue is NamedToken) { // Set the new token value fvd.NamedTokenValue = newFilterValue; } else { // Create a new member object to hold the filter value DashboardMemberValueData mvd = new DashboardMemberValueData();

// Set the new filter value mvd.Values.Add(newFilterValue); mvd.ReadableValues.Add(newFilterValue.ToString());

// Add the member object to the filter fvd.MemberValues.Add(mvd); }

// Add the filter object to the parameter param.FilterValues.Add(fvd);

// Invalidate the filter thus updating any data visualizations connected to it param.InvalidateFilter();


Note: Make sure to change the user variables at the top of the script. Set param to your own parameter name. Set newFilterValue to what you would like to filter by. This can be a string, a number, or a token.

Tokens

A token represents an intelligent selection of values. They can be disabled by toggling the "Token Menu Visibility" property of the parameter control. Tokens are typically used on date-time parameters but you can also use them on categorical and numeric parameters.

There are several types of tokens but the most important distinction is the difference between tokens that represent a single value (i.e. range start and range end) and those that represent an entire range (i.e. date value). The Drop Down List control allows for tokens that represent an entire range. You can read more about scripting with tokens here. A complete list of supported named tokens used for parameter values can be found here.

Note: The above script can handle tokens. The newFilterValue object can be set to a range token (e.g. NamedToken.All to represent all values).

Related Topics


Click to return to: Documentation | Scripting a Parameter Filter

About Dundas | Contact Us Follow us on Twitter! | Privacy Statement | Report Site Issues

Copyright © 2009-2014 Dundas Data Visualization, Inc.