Don't export Nested View Template

4 posts, 0 answers
  1. Shawn
    Shawn avatar
    12 posts
    Member since:
    Sep 2013

    Posted 30 Oct 2015 Link to this post

    I have a RadGrid that contains a NestedView Template.   With the export option, i DO NOT want the NestedView to export (even if the nested view is visible).

     

    While the grid item isn't expanded, i don't see the NestedView data.  However, when one is expanded, it will export.  How do I keep that from happening?

  2. Eyup
    Admin
    Eyup avatar
    3819 posts

    Posted 03 Nov 2015 Link to this post

    Hi Shawn,

    If you are using the IgnorePaging export option, you can use the following logic to achieve this requirement:
    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.ExportToExcelCommandName)
        {
            RadGrid1.MasterTableView.HierarchyDefaultExpanded = false;
        }
    }

    Hope this helps. Please give it a try and let me know if it works for you.

    Regards,
    Eyup
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Shawn
    Shawn avatar
    12 posts
    Member since:
    Sep 2013

    Posted 03 Nov 2015 Link to this post

    Thanks for responding.   Unfortunately, that did not seem to help.  I noticed that value is already set to false before I edit it.   I even tried this: 

    grid.MasterTableView.GroupsDefaultExpanded = false;

    That didn't help either.

  4. Kostadin
    Admin
    Kostadin avatar
    1733 posts

    Posted 06 Nov 2015 Link to this post

    Hello Shawn,

    Which export format you are using? Keep in mind that you need either to rebind the grid or enable IgnorePaging in order to collapse the detail tables. Another possible solution is to hide the NestedViewTemplate when you export the grid. Please check out the following help article.
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridNestedViewItem && RadGrid1.IsExporting)
        {
            e.Item.Visible = false;
        }
    }

    Similarly You should rebind the grid or enable IgnorePaging.

    Regards,
    Kostadin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top