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

Compare with Current View Page History

« Previous Version 11 Next »

How to Use

Creating Callback Function

Table cells can be dynamically colored by using the input parameters of the Callback Function. You can filter tables by ColumnName and Rows.

To use this feature, you will need to add a callback function in the 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:

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.

 

The new colored DataGrid is added into the report following the same logic as before.

Report with Colored DataGrid

Insert a table with the correct number of columns and only TWO rows. In the first column, write the text that will be the column name in the printed report.

In the second column, write the correct column name that is in the database.

Additional Information

Since the callback function is placed into the ClientMain class, the reports containing DataGrids will only be colored if the report is being saved by one of the following methods:

  • Using the SaveCommand method in CodeBehind
  • Using the SaveCommand method in a Task with Client Domain
  • Using a tag in the report SaveTrigger


  • No labels