GridViewSettings.CustomColumnDisplayText Property
Enables you to specify a cell’s display text.
Namespace: DevExpress.Web.Mvc
Assembly: DevExpress.Web.Mvc5.v24.2.dll
NuGet Package: DevExpress.Web.Mvc5
#Declaration
public ASPxGridViewColumnDisplayTextEventHandler CustomColumnDisplayText { get; set; }
#Property Value
Type | Description |
---|---|
ASPx |
A delegate method. |
#Remarks
The CustomColumnDisplayText event occurs for bound and unbound columns. This event allows you to specify the text that is displayed in the grid when its data is printed or exported.
The CustomColumnDisplayText event fires in the following cases:
While the control’s hierarchy is building.
When you sort or filter a grid by display text (the GridDataColumnSettings.FilterMode or the ASPxGridBehaviorSettings.SortMode property is set to DisplayText). In this case, the rows’ visible indexes are not taken into account and the GetFieldValue(int visibleRowIndex, string fieldName) method returns -1.
Note
The Custom
Column event is not in effect for template columns.Display Text The Custom
Column event is not in effect for the GridDisplay Text View column as the grid filters only column values and ignores the display text. To specify the display text for this column, use the DisplayData Check Column Text and DisplayChecked Text properties.Unchecked
#Online Example
GridView - How to filter dates by the month
#Example
This example demonstrates how to display the “empty” string within the “Units On Order” column’s cells if they contain zero values.
@Html.DevExpress().GridView(settings => {
settings.Name = "GridView1";
settings.KeyFieldName = "ID";
...
settings.CustomColumnDisplayText = (sender, e) =>
{
if (e.Column.FieldName != "UnitsOnOrder") return;
if (Convert.ToInt32(e.Value) == 0)
e.DisplayText = "empty";
};
}).Bind(Model).GetHtml()