Back to Devexpress

ASPxTreeList.CustomColumnDisplayText Event

aspnet-devexpress-dot-web-dot-aspxtreelist-dot-aspxtreelist-41abc7d8.md

latest3.8 KB
Original Source

ASPxTreeList.CustomColumnDisplayText Event

Enables custom display text to be provided for any cell.

Namespace : DevExpress.Web.ASPxTreeList

Assembly : DevExpress.Web.ASPxTreeList.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public event TreeListCustomColumnDisplayTextEventHandler CustomColumnDisplayText
vb
Public Event CustomColumnDisplayText As TreeListCustomColumnDisplayTextEventHandler

Event Data

The CustomColumnDisplayText event's data class is TreeListColumnDisplayTextEventArgs. The following properties provide information specific to this event:

PropertyDescription
ColumnGets the processed column.
DisplayTextEnables you to set a custom text for the cell currently being processed.
EncodeHtmlGets or sets a value that specifies whether the cell display text keeps any of its values that are HTML as HTML, or instead, strips out the HTML markers.
NodeKeyGets the processed node’s key value.
ValueGets the edit value of the cell currently being processed.

Remarks

The CustomColumnDisplayText event can be used to provide custom display text for any cell. This event is fired for both bound and unbound columns.

Initially, the TreeListColumnDisplayTextEventArgs.DisplayText parameter returns null. To provide custom display text, assign the required string to this parameter. To get the current cell value, use the TreeListColumnDisplayTextEventArgs.Value parameter.

The CustomColumnDisplayText event fires in two cases.

Note

The CustomColumnDisplayText event should not be handled for template columns.

Example

This example demonstrates how to display the “empty” string within the Units On Order column’s data cells if they contain zero values.

The image below shows the result:

csharp
protected void ASPxTreeList1_CustomColumnDisplayText(object sender, DevExpress.Web.ASPxTreeList.TreeListColumnDisplayTextEventArgs e)
{
    if (e.Column.FieldName != "UnitsOnOrder") return;
    if (Convert.ToInt32(e.Value) == 0)
        e.DisplayText = "empty";
}

See Also

Tree List

ASPxTreeList Class

ASPxTreeList Members

DevExpress.Web.ASPxTreeList Namespace