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.

Color Data Grid Cells Independent of Transpose State

Hide navigation
Modified on Thu, 21 Feb 2013 05:45 PM Categorized as Data Grid
Dundas Dashboard Script LibraryPrevious


This example shows how to use scripting to color data grid cells independent of the grid's transpose mode.

The basic idea is to apply coloring based on the data within cells, which is the same regardless of whether the data grid is transposed or not.


Prepare a dataset and display it as a data grid on your dashboard:

Dataset displayed in data grid.

Dataset displayed in data grid.

Add a Button control to the dashboard and set its Text property to Transpose.



Add a Row Loaded interaction script as listed below. This script colors cells in the Product SKU column when the Number of Downloads value is greater than 50.

if (e.VisualElementArgs != null) { foreach (DashboardDataGridCell cell in e.VisualElementArgs.Cells) { // Figure out the cell to color // In this example the header text is used if (cell.DashboardDataGridDataMemberColumn != null && cell.DashboardDataGridDataMemberColumn.HeaderText == "Product SKU") { // Get the value that the coloring will be based on. // It doesn't have to be the same column as the cell // that is being colored. // ! NOTE ! The string parameter in the // call below is the name of the KPI/Dataset column and // not to be confused with the data grid column header text double num = (double)DataGrid1.DataDescriptors[0].GetDataPointColumnValue(cell.DataSource, "Number of Downloads"); if (num > 50) { cell.Background = new DashboardSolidColorBrush(Colors.Green); } else { cell.Background = null; } } } }


Add the following Click interaction script to the button. This script toggles the transpose state of the data grid.

DataGrid1.View.IsTransposed = !DataGrid1.View.IsTransposed;


Test this example by previewing the dashboard, and then clicking the Transpose button.

Transposed data grid with color cells.

Transposed data grid with color cells.

Related topics

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

Copyright © 2009-2014 Dundas Data Visualization, Inc.