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.

Using Script Module to Set a Value to a Dynamic Parameter

Hide navigation
RSS
Modified on Wed, 19 Mar 2014 10:50 AM Categorized as Level-Advanced, Level-Expert, Level-Intermediate, Parameter Controls, Parameters, Scripting
Dundas Dashboard Script LibraryPrevious


Overview

This article shows how to use the Script Module in order to pass a parameter values to a dynamic Parameter control.

Prerequisites


Setting up the Script Module

Using Regular Script

Different scripts are required depending on the type of Parameter control. Sample scripts can be found on the Setting Filter Parameter Values page. For example here is the script required when setting a value on a Drop Down List parameter 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();



Using Script Module

As you can see from the script below, you just need to add a few lines of code to convert the regular script to a script module. Here, a public reference is used, which means that the function is accessible to callers outside of the script module.

Script Module script.

Script Module script.




public void SetDropDownValue (object myparam, object myvalue) { /******************** USER VARIABLES ********************/ object param = myparam; // your parameter object newFilterValue = myvalue; // 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(); }



Calling the Script

Tip: Make sure you've already added a reference to the script module before you can use the script.

For example, if you want to call the script module and pass the parameter name and a string parameter value, you can use similar script below. Make sure you use the correct script module name, function name, parameter name (without the quotes), and filter value:

ScriptModule.SetDropDownValue(myParameter, "myvalue");

Related Topics


Click to return to: Documentation

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

Copyright © 2009-2014 Dundas Data Visualization, Inc.