Skip to main content

ASPxTreeList.CustomUnboundColumnData Event

Enables data to be supplied to unbound columns.

Namespace: DevExpress.Web.ASPxTreeList

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

NuGet Package: DevExpress.Web

Declaration

public event TreeListCustomUnboundColumnDataEventHandler CustomUnboundColumnData

Event Data

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

Property Description
Column Gets the processed column.
Node Gets the node currently being processed. Inherited from TreeListNodeEventArgs.
Value Gets the edit value of the cell currently being processed.

Remarks

The CustomUnboundColumnData event is fired for unbound columns only. To create an unbound column, add a new data column to the ASPxTreeList.Columns collection and set its TreeListDataColumn.UnboundType property to an appropriate value, based on the type of data the column is supposed to display. This column’s TreeListDataColumn.FieldName property value must be unique and it must not refer to any field in the ASPxTreeList’s underlying data source.

When the ASPxTreeList is loaded, it raises the CustomUnboundColumnData event for each data cell in unbound columns, allowing you to populate cells with data.

The currently processed cell is identified by the column and node, which can be determined via the TreeListCustomUnboundColumnDataEventArgs.Column and TreeListNodeEventArgs.Node properties, respectively.

The CustomUnboundColumnData event argument provides the TreeListNode.GetValue method, allowing you to get the value of the required cell.

Example

Assume that ASPxTreeList is bound to an “Order Details” data table (NWind data base), which contains “UnitPrice”, “Quantity” and “Discount” fields. There is no field that represents the total sum, as this can be calculated manually as follows: UnitPrice*Quantity*(1-Discount). This example shows how to add an unbound column to the ASPxTreList control to represent the total sum of an order.

The image below shows the result.

ASPxTreeList-CustomUnboundColumnData

protected void TreeList_CustomUnboundColumnData(object sender, TreeListCustomUnboundColumnDataEventArgs e)
{
    if (e.Column.FieldName == "Total") {
        decimal unitPrice = Convert.ToDecimal(e.Node.GetValue("UnitPrice"));
        decimal quantity = Convert.ToDecimal(e.Node.GetValue("Quantity"));
        decimal discount = Convert.ToDecimal(e.Node.GetValue("Discount"));
        e.Value = unitPrice * quantity * (1 - discount);
    }
} 
See Also