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. Image for the cookie policy date
close icon

Call a custom function to transform cell contents

I've looked at the sample code for the "Conditional Formatting" and "Column Formatting" but I'd like to go beyond that. For instance I want to prefix or post-fix the text with custom strings base on the content.

Currently I do it using the Custom class, that derives from ITemplate, but it's quite cumbersome and also the end result does not affect grouping, as the original data is used for grouping and sorting purposes.

Hopefully there's an easier way to do what I want. Any suggestions are appreciated.

1 Reply

RP Rekha P Syncfusion Team July 6, 2009 07:46 AM UTC

Hi Vasili,

Thank you for your interest in Syncfusion Products.

You can customize the Grid cell text when Data is bound to a Row through RowDataBound event handler. Please refer a simple code snippet below to achieve this.

void GridGroupingControl1_RowDataBound(object sender, RowDataBoundEventArgs e)
{
////// Gets the Current Record Row Element Bound.
if (e.Element.Kind == DisplayElementKind.Record)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
/////// Check for column name.
if (((Syncfusion.Web.UI.WebControls.Grid.Grouping.GridCell)(e.Row.Cells[i])).ColumnDescriptor.Name == "Name")
{
e.Row.Cells[i].Text = "AA " + e.Row.Cells[i].Text + " BB";
}
}
}
}


The steps followed here are,
- Get the RowDataBound event.
- Check if that Row is Grid Record row, if so Iterate the Grid cells .
- Check for column name and modify the GridCell value.

Thanks,
Rekha

Loader.
Live Chat Icon For mobile
Up arrow icon