ASPxCardView.CustomColumnDisplayText Event
Enables custom display text to be provided for any column.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.2.dll
NuGet Package: DevExpress.Web
#Declaration
public event ASPxCardViewColumnDisplayTextEventHandler CustomColumnDisplayText
#Event Data
The CustomColumnDisplayText event's data class is ASPxCardViewColumnDisplayTextEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Column | Gets the data column that refers to the card currently being processed. |
Display |
Enables you to set a custom text for the cell currently being processed.
Inherited from ASPx |
Encode |
Gets 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.
Inherited from ASPx |
Kind |
Gets the type of operations with grid data.
Inherited from ASPx |
Value |
Gets the edit value of the cell currently being processed.
Inherited from ASPx |
Visible |
Gets the visible index of the data item (row, card or record) where the processed cell resides.
Inherited from ASPx |
The event data class exposes the following methods:
Method | Description |
---|---|
Get |
Returns the value of the specified data source field in the specified data item (row, card or record).
Inherited from ASPx |
Get |
Returns the value of the specified data source field in the current data item (row, card or record).
Inherited from ASPx |
#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. The text provided via this event will be used when the ASPxCardView is printed or exported.
Initially, the ASPxGridColumnDisplayTextEventArgs.DisplayText parameter returns null. To provide custom display text, assign the required string to this parameter. To get the current cell value, use the ASPxGridColumnDisplayTextEventArgs.Value parameter.
The CustomColumnDisplayText event fires in two cases.
- When the control hierarchy is being built.
- When a grid is filtered or sorted by display text (the GridDataColumnSettings.FilterMode or the GridDataColumnSettings.SortMode property is set to DisplayText). In this case, the grid card visible indexes are not identified when the event fires. The ASPxGridColumnDisplayTextEventArgs.VisibleIndex argument property returns -1. Therefore, you cannot use the GetFieldValue(int visibleRowIndex, string fieldName) overload of the ASPxGridColumnDisplayTextEventArgs.GetFieldValue method to get the value of the non-processed card.
Note
The Custom
#Example
The following example displays the “empty” string within the Discount column’s cells if they contain zero values.
The image below shows the result:
protected void CardView_CustomColumnDisplayText(object sender, ASPxCardViewColumnDisplayTextEventArgs e) {
if (e.Column.FieldName != "Discount") return;
if (Convert.ToInt32(e.Value) == 0)
e.DisplayText = "empty";
}