416.467.9100 | Dundas Data Visualization | Login
Welcome Guest
Dashboard v5.0

This site makes extensive use of JavaScript.

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

Setting Filter Values to Multiple Parameters By Script

Hide navigation
RSS
Modified on Wed, 19 Mar 2014 11:05 AM Categorized as Parameters, Script Library, Scripting
Dundas Dashboard Script LibraryPrevious

Overview

This article shows how to use scripting in setting a NamedToken value to multiple parameters.

Tip: If you simply need to set all parameters to its default values, you can use NavigateToDashboard to navigate/reopen the same dashboard.

Set All Parameters to All values

Script below will set All Parameters to All values:

foreach (DashboardParameter dp in services.CurrentDashboard.DashboardParameters)
{
    DashboardFilterValueData filter = new DashboardFilterValueData();
    filter.NamedTokenValue = NamedToken.All;
    dp.FilterValues.Clear();
    dp.FilterValues.Add(filter);
    dp.InvalidateFilter();    
}

Tip: Each time InvalidateFilter() is called, the Parameter Changed Interaction is fired and data is retrieved. If this is causing Performance or Timing Issues, you can check the article on Using the Disable Loading Data property.

Set All DropDownList Parameters to All values

Script below will set All DropDownList Parameters to All values:

foreach (DashboardParameter dp in services.CurrentDashboard.DashboardParameters)
{
    string type = dp.ParameterControlTypeName;
    if(type.Contains("DropDownList")) 
    {
        DashboardFilterValueData filter = new DashboardFilterValueData();
        filter.NamedTokenValue = NamedToken.All;
        dp.FilterValues.Clear();
        dp.FilterValues.Add(filter);
        dp.InvalidateFilter();
    }
}

Note: In the above sample, the returned value for the string variable type is Dundas.Dashboard.DashboardControls.ParameterDropDownList, and the C# function Contains is used to search for the DropDownList string within the type variable.

Tip: For other Parameter Control Types, you can use the TRACE directive and see the Parameter Control Type associated with a particular parameter.

for example:

foreach (DashboardParameter dp in services.CurrentDashboard.DashboardParameters)
{
    string type = dp.ParameterControlTypeName;    
    #TRACE type;
    if(type.Contains("DropDownList")) 
    {
        DashboardFilterValueData filter = new DashboardFilterValueData();
        filter.NamedTokenValue = NamedToken.All;
        dp.FilterValues.Clear();
        dp.FilterValues.Add(filter);
        dp.InvalidateFilter();
    }
}

Script Console showing the values for ParameterControlTypeName . As seen from the screenshot, only the DropDownList parameter control is updated with All values .

Script Console showing the values for ParameterControlTypeName. As seen from the screenshot, only the DropDownList parameter control is updated with All values.



Set Only Specific Parameters to All values

Script below will set Only Specific Parameters to All values. In this sample, the parameters that will be updated are named Parameter1 and Parameter2.

foreach (DashboardParameter dp in services.CurrentDashboard.DashboardParameters)
{
    string name = dp.Name;
   
    if(name == "Parameter1" || dp.Name == "Parameter2" )
    {
        DashboardFilterValueData filter = new DashboardFilterValueData();
        filter.NamedTokenValue = NamedToken.All;
        dp.FilterValues.Clear();
        dp.FilterValues.Add(filter);
        dp.InvalidateFilter();
    }
}

Reset All Parameters to its Default values

Script below will reset All Parameters to its Default values:

foreach (DashboardParameter dp in services.CurrentDashboard.DashboardParameters)
{
    DashboardFilterValueData filter = new DashboardFilterValueData();
    filter.NamedTokenValue = NamedToken.Default;
    dp.FilterValues.Clear();
    dp.FilterValues.Add(filter);
    dp.InvalidateFilter();    
}

Tip: Besides the Named Tokens All values and Default, you can also use any compatible named token values for your parameters.

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.