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

Remove Row on Export

1 Answer 135 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jerry
Top achievements
Rank 2
Iron
Iron
Jerry asked on 18 Feb 2021, 09:44 PM
How do I remove rows on Biff Export?  I want them to be visible in the app but removed when exported if a particular column has a null value.

1 Answer, 1 is accepted

Sort by
0
Doncho
Telerik team
answered on 23 Feb 2021, 01:07 PM

Hi Jerry,

You can set the Visible property of certain GridDataItems to false when the RadGrid is being rendered for exporting, see Hiding Columns / Rows

For example, in the PreRender event of the grid,  check if the RadGrid is being exported, and loop through its items to disable the visibility of the desired rows:

protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    if (RadGrid1.IsExporting)
    {
        var dataItems = RadGrid1.Items;
        foreach (GridDataItem item in dataItems)
        {
            //opt1. check for the text in a cell
            //if (string.IsNullOrEmpty(item["ShipName"].Text))
                
            //opt2. get a key value
            if (item.GetDataKeyValue("OrderID").ToString() == "6")
            {
                item.Visible = false;
            }
        }
    }
}

I hope this will help. Please let me know if you have further questions.

Kind regards,
Doncho
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Jerry
Top achievements
Rank 2
Iron
Iron
Answers by
Doncho
Telerik team
Share this question
or