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

Change cell value on load

Hi,

I am loading my data in GrdiGroupingControl which is working fine. However, in one of the columns I would like to trim the values when the page loads. somthing like below:

if the actual value from database is: ABCD:EFGH, then i would like to display only EFGH.

Could you please advice how to do this?

Thanks,
Navin


1 Reply

SN Sridhar N Syncfusion Team May 23, 2011 08:35 AM UTC

Hi Navin,

Thanks for your interest in Syncfusion products.

Query #1"Change cell value on load"

Your requirement can be achieved by changing the value of cell using CellValue in QueryCellStyleInfo event. Please refer the below code snippet.

[Codebehind - C#]

void ggc_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell)
{
if (e.TableCellIdentity.Column.MappingName == "Group")
{
string cellval = e.Style.CellValue.ToString();
if(cellval.StartsWith("ABCD:"))
{
// Trim the value.
cellval = cellval.TrimStart('A');
cellval = cellval.TrimStart('B');
cellval = cellval.TrimStart('C');
cellval = cellval.TrimStart('D');
cellval = cellval.TrimStart(':');
//Change the value using CellValue
e.Style.CellValue = cellval;
}
}
}
}


For your convenience, we have created sample and the same can be downloaded from the following link.

Forum1049508762.zip

Please let me know if you have any other questions or concerns.

Regards,
Sridhar.N



Loader.
Live Chat Icon For mobile
Up arrow icon