How can I replace the cell content with another value

Hello,

I use the GridGroupingControl version 14.4400.0.15.

I would like to display all cell contents with the value 0 in the
an empty string.
See attached image

How can I do this

kindest regards
Bernhard Höhn


Attachment: ReplaceZero_c2bb96c8.rar

1 Reply

AR Arulpriya Ramalingam Syncfusion Team May 12, 2020 09:17 PM UTC

Hi Bernhard, 
 
Thank you for your interest in Syncfusion products. 
 
The GridGroupingControl does not have any built-in support to set default value for column however, this can be achieved by customizing the QueryCellStyleInfo event. In that event, the Text property can be updated with default value based on conditions. We have created a simple sample as per your requirement. Please make use of below code and sample. 
 
Example code 
 
this.gridGroupingControl1.TableDescriptor.Fields["PF"].DefaultValue = "0"; 
//Event subscription 
this.gridGroupingControl1.QueryCellStyleInfo += GridGroupingControl1_QueryCellStyleInfo; 
 
//Event customization 
private void GridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e) 
{ 
   if(e.TableCellIdentity != null && e.TableCellIdentity.Column != null && e.TableCellIdentity.Column.Name == "PF" 
        && e.Style.CellValue != null && string.IsNullOrEmpty(e.Style.CellValue.ToString())) 
    { 
        e.Style.Text = "0"; 
        e.Handled = true; 
    } 
} 
 
 
Please let us know, if you need any further assistance. 
 
Regards, 
Arulpriya 


Loader.
Up arrow icon