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.

How to use a Global Variable

Hide navigation
RSS
Modified on Thu, 22 May 2014 04:00 PM Categorized as Script Library, Scripting

Overview

This article shows how to store and retrieve values from a global variable using the services.Globals object. Check this link for more details on the services library: services - Global object

This is useful for storing variables for the script across dashboards (within the same browser session). For all different types of examples, see the Examples section in this article.

While the most common usage is to pass values through the global variable, they can also be used to pass entire objects such as dropdown lists, controls etc. from the source to the target and retrieve their properties on the target. See the example below on how to pass a dropdown list.

Tip: Watch the how-to video: How to use a Global Variable

Store value



int value = 10; //Object of any type can be stored in a global vaiable such as string, DataPoint, DashboardContent, DashboardDataGridRow etc.

services.Globals“Variable_Name” = value; //Store the value into the global variable.



Another way to set a global variable is to first check if the key already exists and if it does, then remove it first it.



if (services.Globals.ContainsKey("Variable_Name ")) // Check if the key is present { services.Globals.Remove("Variable_Name "); } services.Globals.Add("Variable_Name",value); //Store the value into the global variable.



Retrieve value



int global_value = new int; //Declare the object that will contain the value returned from the global variable.

global_value = services.Globals“Variable_Name”; //Retrieve the value from the global variable



Examples

This example shows how to store and retrieve a dropdown list using a global variable. Dropdowns are stored as arrays and are retrieved as an array:



//Store Dropdown services.Globals"ddlist" = DropDownList1;

//Retrieve dropdown. This can be added to the load interaction of a drill down dashboard. DashboardDropDownList dd = services.Globals"ddlist";

  1. TRACE dd.Items.Count;
  2. TRACE dd.Items0;



For other practical examples on how the global variable is used with different data types, see the samples below:


Related Topics

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

Copyright © 2009-2014 Dundas Data Visualization, Inc.