You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Introduction

This document provides information on how to format individual cells in a DataGrid dynamically and print them in a Report.

How to Use

Creating Callback Function

To use this feature, you will need to add a callback function into ClientMain Class that is called every time the DataGrid is modified.

The function has the following syntax:

public void OnReportCustomTableCell(string reportName, string columnName, System.
Data.DataRow row, System.Windows.Documents.TableCell tableCell)
{
// Insert Code Here
}


In this example we will add the following table to our Report:

Sample Table.


It is possible to dynamically color the Table Cells using the input parameters of the Callback Function. You can filter by ColumnName and Rows.

Callback Function Usage

The code below shows an example of how this feature can be implemented.

public void OnReportCustomTableCell(string reportName, string columnName, System.
Data.DataRow row, System.Windows.Documents.TableCell tableCell)
{
if (columnName == "Age")
{
if (TConvert.To<int>(row["Age"]) == 40) 
tableCell.Background = Brushes.Red;

else if (TConvert.To<int>(row["Age"]) < 30) 
tableCell.Background = Brushes.Yellow;

else
tableCell.Background = Brushes.Green;
}

if (row["Country"].ToString() == "Brazil") 
tableCell.Background = Brushes.Coral;
}


The result achieved by the example code is presented in the image below.

Colored Sample Table.

 

The new Colored DataGrid is added into the Report following the same logic as before.

Report with Colored DataGrid

You will need to insert a table, with the correct number of columns and only TWO rows. In the first column you will write the text that will appear as Column Name in the printed report.

In the second column you will write the correct Column Name as in the Database.

How to add a Table to a Report.

Additional Information

Since the callback function is placed into ClientMain Class, the Reports containing DataGrids will only be colored if the Report is being saved in one of the following methods:

  • Using the SaveCommand method in CodeBehind.
  • Using the SaveCommand method in a Task with Client Domain.
  • Using a Tag into the Report SaveTrigger

Report save properties.


  • No labels