New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

Hide Add/Edit Columns in RadTreeList Export to Excel

Environment

Version2019.3.1023
ProductRadTreeList 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.

C#
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;
        }
    }
}

See Also