TreeListExportCustomizeCellEventArgs.DataItem Property
Returns the data source item that is bound to the data row being processed.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v24.2.dll
NuGet Package: DevExpress.Blazor
Declaration
public object DataItem { get; }
Property Value
Type | Description |
---|---|
Object | If the processed cell belongs to a data row, the property returns a data item bound to this row. Otherwise, the property returns |
Remarks
Use the DataItem
property to get the data source item that is bound to the data row being processed. If the current cell does not belong to a data row (the AreaType property returns a value other than DataArea
), the DataItem
property returns null
.
Pass the DataItem
property value to the GetDataItemValue method to get the item’s field value when the TreeList is bound to a collection of anonymous objects. In other cases, you can cast the DataItem
property value to the corresponding type and use the {DataItem.FieldName}
notation to get the item’s field value.
The following example adds a hyperlink to the document’s Name column:
async Task ExportXlsx_Click() {
await MyTreeList.ExportToXlsxAsync("ExportResult", new TreeListXlExportOptions() {
CustomizeCell = CustomizeCell
});
}
void CustomizeCell(TreeListExportCustomizeCellEventArgs e) {
if (e.AreaType == DevExpress.Export.SheetAreaType.DataArea && e.ColumnFieldName == "Name") {
var product = e.DataItem as TestModel;
e.Hyperlink = product.Url;
e.Handled = true;
}
};