We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Call a custom function to transform cell contents

Thread ID:





84816 Jul 2,2009 07:39 PM UTC Jul 21,2009 12:27 PM UTC ASP.NET Web Forms (Classic) 3
Tags: GridGroupingControl
Vasili Sviridov
Asked On July 2, 2009 07:39 PM UTC

Is there a way to call a custom function on cell content and have it persistent. So when grouping is applied - transformed value is used.

Rekha P [Syncfusion]
Replied On July 13, 2009 04:25 AM UTC

Hi Vasili,

Thank you for your interest in Syncfusion Products.

The GridGroupingControl, when bound to a data source, can be used to perform engine-related operations such as grouping, allowing you to categorize records based on a specific column. The custom grouping can also be enabled on various grid columns and the grouping collections can be maintained. Please refer the Grouping Demo online sample from the link below,


Have a look at the above sample and let me if this helps you or could you please more specific about your requirement, so that we can look into that and provide you a solution quickly.


Vasili Sviridov
Replied On July 20, 2009 08:47 PM UTC

Ok, here's the scenario.

I obtain a DataSet with my report data. The data is in the raw form. For instance the distance is stored in meters per second.

In my report I'd like to format that as either km/h or MPH, depending on the user's preference. I also want to have the text part localized. I could do it all either in Database or in the dataset, prior to getting databound in syncfusion control. But If i do that and have the data as string, then all the grouping and summary capabilities could not be used.

So currently I resort to overriding QueryCellInfo method and using the TableCellIdentity..DisplayTemplate. To override it with my custom ITemplate, containing formatted string. This way I can have the flexibility of summaries on original data, and custom display. However since it's a template - formatted text is not propagated into the Headers for grouped columns. Original double value is displayed there.

Since this way is quite convoluted, I'd like to know whether or not there is an easier way of achieving the same result.

Screenshot attached.



Balaji M [Syncfusion]
Replied On July 21, 2009 12:27 PM UTC

Hi Vasili,

Thank you for your interest in Syncfuion Products.

Using queryCellStyleInfo event, we can format the reported GroupedHeaderCaption issue.

Please refer the following code snippet,

void GridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Web.UI.WebControls.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
// if the Celltype is RecordFieldCell or AlternateRecordFieldCell then format the record rows
if (e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell)
if (e.TableCellIdentity.Column.Name == "Duration")
//Format the Column Duration using formula
e.Style.CellValue = ((Convert.ToInt32(e.Style.CellValue) / (60 * 60))) + "h**" + ((Convert.ToInt32(e.Style.CellValue) / 60) % 60) + "m **" + (Convert.ToInt32(e.Style.CellValue) / (3600 * 60)) + "s";
e.Handled = true;

else if (e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionCell)
// if Column is grouped then split the GroupCaptionCell
if (this.GridGroupingControl1.TableDescriptor.IsGrouped)
string[] groupedCellValues = e.Style.CellValue.ToString().Split('-', ':');
if (groupedCellValues[0].IndexOf("Duration") != -1)
//Format the Column Duration using formula
string s1 = (Convert.ToInt32(groupedCellValues[1]) / 3600) + "h **" + ((Convert.ToInt32(groupedCellValues[1]) / 60) % 60) + "m **" + ((Convert.ToInt32(groupedCellValues[1]) / (3600 * 60))) + " s";
e.Style.CellValue = groupedCellValues[0]+ ": " + s1 + "-" +groupedCellValues[2];

Please refer the sample from below link.


The above sample illustrates, the Column "Duration" & GroupCaptionCell are formatted (Custom) using formula in QueryCellInfo event.

Please let me know if this helps you out.

M. Balaji


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon