Hide Add/Edit Columns in RadTreeList Export to Excel
Environment
Version | 2019.3.1023 |
Product | RadTreeList for ASP.NET AJAX |
Description
When exporting to Excel in a RadTreeList that contains an EditColumn, the Add and Edit text will also appear.
Solution
To change this set the Visible property to false in the ItemDataBound event handler. Use the IsExporting flag to verify the Export Command is being executed. See the below code snippet for reference.
protected void rtlOrgChart_ItemDataBound(object sender, TreeListItemDataBoundEventArgs e)
{
var tl = (RadTreeList)sender;
if (tl.IsExporting)
{
foreach (var col in tl.Columns)
{
if (col is TreeListEditCommandColumn)
col.Visible = false;
}
}
}
Protected Sub rtlOrgChart_ItemDataBound(sender As Object, e As TreeListItemDataBoundEventArgs) Handles rtlOrgChart.ItemDataBound
Dim tl = CType(sender, RadTreeList)
If tl.IsExporting Then
For Each col In tl.Columns
If TypeOf col Is TreeListEditCommandColumn Then
col.Visible = False
End If
Next
End If
End Sub