This is a migrated thread and some comments may be shown as answers.

hidden DetailTemplateItemDataCell causes blank Excel row

2 Answers 66 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Benjamin
Top achievements
Rank 1
Benjamin asked on 10 Apr 2020, 06:12 PM

I am hiding the detail template item in the OnItemDataBound method which works, but this causes a blank row when I export to Excel.  How can the row be removed completely?

Dim item = CType(e.Item, GridDataItem)

item.DetailTemplateItemDataCell.Visible = false

2 Answers, 1 is accepted

Sort by
0
Accepted
Attila Antal
Telerik team
answered on 13 Apr 2020, 03:10 PM

Hi Benjamin,

The method from your description only hides the Cell inside the DetailTemplateItem, but the item itself remains visible.

To hide them when exporting, try the following example:

protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    if (RadGrid1.IsExporting)
    {
        foreach (GridDetailTemplateItem detailTemplateItem in RadGrid1.MasterTableView.GetItems(GridItemType.DetailTemplateItem))
        {
            detailTemplateItem.Visible = false;
        }
    }
}

 

Kind regards,
Attila Antal
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Benjamin
Top achievements
Rank 1
answered on 13 Apr 2020, 07:04 PM
That worked, thanks!
Tags
Grid
Asked by
Benjamin
Top achievements
Rank 1
Answers by
Attila Antal
Telerik team
Benjamin
Top achievements
Rank 1
Share this question
or