blazor-devexpress-dot-blazor-dot-dxgrid-7e8cb316.md
Allows you to customize text displayed within a cell.
Namespace : DevExpress.Blazor
Assembly : DevExpress.Blazor.v25.2.dll
NuGet Package : DevExpress.Blazor
[Parameter]
public Action<GridCustomizeCellDisplayTextEventArgs> CustomizeCellDisplayText { get; set; }
| Type | Description |
|---|---|
| GridCustomizeCellDisplayTextEventArgs |
A GridCustomizeCellDisplayTextEventArgs object that contains data for this event.
|
You can handle the CustomizeCellDisplayText event or use a column’s DisplayFormat property to customize a cell’s display text. On export, the event handler logic applies only if the ExportDisplayText option is enabled.
Use GridCustomizeCellDisplayTextEventArgs (Value, FieldName, etc.) to specify the display format and access other grid data.
If you implement DataColumnCellDisplayTemplate or CellDisplayTemplate, the CustomizeCellDisplayText event fires in the following cases only:
The following code snippet add the dollar sign to the Value column’s cell display text:
<DxGrid Data="Data"
CustomizeCellDisplayText="Grid_CustomizeCellDisplayText">
<Columns>
<DxGridDataColumn FieldName="Product" />
<DxGridDataColumn FieldName="Value" />
</Columns>
</DxGrid>
@code {
private List<object> Data = [];
protected override void OnInitialized() {
List<string> Products = new List<string> { "Soda", "Cookies", "Milk", "Candy", "Chicken", "Eggs", "Cheese", "Cereal", "Vegetables", "Berries" };
for (int i = 1; i <= 10; i++) {
int Value = i * 100;
Data.Add(new() { Product = Products[i - 1], Value = Value });
}
}
void Grid_CustomizeCellDisplayText(GridCustomizeCellDisplayTextEventArgs e) {
if (e.FieldName == "Value") {
e.DisplayText = $" ${e.Value}" ;
}
}
}
Note
Columns bound to boolean fields automatically display checkboxes instead of text. As a result, the CustomizeCellDisplayText event does not fire. To use this event, set the column’s ShowCheckBoxInDisplayMode property to false.
See Also