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

NestedViewTemplate RadGrid Exporting Hidden Columns

1 Answer 30 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gerrit du Preez
Top achievements
Rank 1
Gerrit du Preez asked on 06 Sep 2013, 09:11 AM
Hi,

I'm having some issue with export selected columns and I hope you can help me with it.

On my page I have a RadGrid_Parent that uses an sqldatasource with autogeneratecolumns='false'
inside the RadGrid_Parent I'm making use of the NestedViewTemplate to expand or collapse the selected row.

When the RadGrid_Parent expands it opens another RadGrid_Child AutoGeneratedColumns='true' EnableHeaderContextMenu='true' that uses needdatasource advanced databinding.

The problem I'm having is when i try to export the nestedview RadGrid_Child that uses the advanced data binding it exports all the columns it ignores any column I hide using the EnableHeaderContextMenu

I also tried to make the columns display and visible false in the ItemCommand section but it still picks up columns as display all.

Example of the ItemCommand code as mentioned in sentence above.
 
if (e.CommandName == Telerik.Web.UI.RadGrid.ExportToExcelCommandName ||
            e.CommandName == Telerik.Web.UI.RadGrid.ExportToWordCommandName ||
            e.CommandName == Telerik.Web.UI.RadGrid.ExportToCsvCommandName ||
            e.CommandName == Telerik.Web.UI.RadGrid.ExportToPdfCommandName)
        {
            foreach (GridColumn col in RadGridChild.MasterTableView.AutoGeneratedColumns)
            {
                if (!col.Display)
                {
                   col.Display = false;
                    col.Visible = false;
                }
            }
          }

Any help would be greatly appreciated.

Kind Regards

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 10 Sep 2013, 02:07 PM
Hi,

I guess you are hiding the columns from the client side using the HeaderContextMenu.The changes made in the client side are not reflected in the server side.Hence if you try to access the hidden columns in server side,they are no longer hidden,and the hidden columns doesn't effect during export.Please try hidding the columns from server side.

C#:
protected void RadGrid1_PreRender1(object sender, EventArgs e)   
    {    //Some condition
        RadGrid1.MasterTableView.GetColumn("TitleOfCourtesy").Visible = false;  //Code to hide a column 
    }

Thanks,
Princy
Tags
Grid
Asked by
Gerrit du Preez
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or