416.467.9100 | Dundas Data Visualization | Login
Welcome Guest
Dashboard v2.5

This site makes extensive use of JavaScript.

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

Get the column name and cell value of a data grid on click

Hide navigation
Modified on Thu, 09 Dec 2010 05:15 PM Categorized as Data Grid, How-to, Scripting
Dundas Dashboard Script LibraryPrevious

This script will allow you determine the column name and the value of the cell when a data grid is clicked.

The script will also work if the columns are re-ordered in the data grid.

Note: You will have to change the script to reflect your column and control names.


Place this script in the data grid's Click Interactions list.

// Get the cell being clicked
object cell = e.VisualElementArgs;

// Get the row and column of cell object row = cell.DashboardDataGridRow; object col = cell.DashboardDataGridDataMemberColumn;

// Get the datapoint associated with the row object dp = row.DataPoint;

// Get the clicked column's index (relative to datapoint) based on the Id of the column as it appears in the grid int clickedColumnIndex = DataGrid1.DataDescriptors[0].DataResult.GetColumnIndex(e.ColumnId);

// Get the clicked column's name string clickedColumnName = col.ToString();

// Get the value associated with the cell string clickedCellValue = dp.FieldValues[clickedColumnIndex];

// Show the output in a message box string msg = string.Empty;

msg += "Clicked cell column name : " + clickedColumnName + "\r\n"; msg += "Clicked cell value : " + clickedCellValue;


Sample output

Sample output of clicking on the grid.

Sample output of clicking on the grid.

Related topics

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

Copyright © 2009-2012 Dundas Data Visualization, Inc.