A newer version of this page is available. Switch to the current version.

GridViewSettings.CustomColumnDisplayText Property

Enables you to specify a cell's display text.

Namespace: DevExpress.Web.Mvc

Assembly: DevExpress.Web.Mvc5.v18.2.dll

Declaration

public ASPxGridViewColumnDisplayTextEventHandler CustomColumnDisplayText { get; set; }
Public Property CustomColumnDisplayText As ASPxGridViewColumnDisplayTextEventHandler

Property Value

Type Description
ASPxGridViewColumnDisplayTextEventHandler

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 CustomColumnDisplayText event is not in effect for template columns.

  • The CustomColumnDisplayText event is not in effect for the GridViewDataCheckColumn column as the grid filters only column values and ignores the display text. To specify the display text for this column, use the DisplayTextChecked and DisplayTextUnchecked properties.

Online Example

GridView - How to filter dates by the month

Examples

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()
See Also