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.

Expanding Data Grid Row Groups

Hide navigation
RSS
Modified on Thu, 17 Oct 2013 11:17 AM Categorized as Data Grid, Script Library, Scripting
Dundas Dashboard Script LibraryPrevious


Overview

This example shows how to use scripting to programmatically expand data grid row groups.

Setup

Create a dataset New Dataset with 3 columns and display it in a data grid on your dashboard.

Data grid with 3 columns.

Data grid with 3 columns.


Use group descriptions to set up two levels of grouping in the data grid as follows:

  1. Add a new group description:
    • Set its Data Column property to [New Dataset].[Product Group Name].
    • Set its Text property to Product Group Name.
  2. Add a second group description:
    • Set its Data Column property to [New Dataset].[Product SKU].
    • Set its Text property to Product SKU.

Data grid with 2 levels of grouping.

Data grid with 2 levels of grouping.


Expanding row groups for a specific data point

To expand the row groups for a specific data point, such as Product SKU = “SOOR”, add the following script to a Row Loaded interaction:

if (e.VisualElementArgs.DataPoint == null) { DashboardDataGridRow row = e.VisualElementArgs; object dataSource = row.DataSource; DataPoint dataPoint = null; int level = 0; while (dataPoint == null && dataSource != null) { for (int i = 0; i <= level; i++) { if (dataSource.Items[0] is DataPoint) { dataPoint = dataSource.Items[0]; break; } else { dataSource = dataSource.Items[0]; } }

level++; }

if (dataPoint != null && dataPoint.FieldValues[1].ToString() == "SOOR") { row.IsExpanded = true; } }


Next, preview the dashboard and data grid.

Row groups for a specific data point are automatically expanded upon preview.

Row groups for a specific data point are automatically expanded upon preview.


Expanding the first level of grouping

Use the following script in a Row Loaded interaction in order to expand just the first level (&ie; level 0) of row grouping. The script also uses global values to store the list of altered rows so that user action is not overwritten.

if (e.VisualElementArgs.DataPoint == null) { DashboardDataGridRow row = e.VisualElementArgs; if (row.IsExpandable) { List updatedExpanded; if (services.Globals.ContainsKey("updated_expanded")) { updatedExpanded = services.Globals["updated_expanded"]; } else { updatedExpanded = new List(); services.Globals["updated_expanded"] = updatedExpanded; } string groupName = row.DataSource.Name; if (!updatedExpanded.Contains(groupName)) { if (row.Level == 0) { updatedExpanded.Add(groupName); row.IsExpanded = true; } } } }

Next, preview the dashboard and data grid.

Expanding just the first level of grouping.

Expanding just the first level of grouping.


Related topics


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

Copyright © 2009-2014 Dundas Data Visualization, Inc.