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

Hide columns in excel

1 Answer 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sudheer
Top achievements
Rank 2
sudheer asked on 23 Feb 2009, 10:58 AM
Hi

i have a rad outlook style grid . while exporting grid into excel sheet want to hide particular columns(Edit ,Delete)  in excel  sheet.
In common grid  and hierarchical grid i achieved this issue like
Gridname.MasterTableView.Columns[i].Visible
= false
Gridname.MasterTableView.DetailsTables[0].Columns[i].Visible = false
, but in  outlook grid Edit and delete columns header text and item data null but those two columns getting display . but i don't want display those columns .


Thanks for any help.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Feb 2009, 12:53 PM
Hello Sudheer,

Are you using AutoGeneratedDelete and AutoGeneratedEdit Columns? If so, try out the following code to hide the columns in the MasterTable and the DetailTables:
cs:
protected void ExportButton_Click(object sender, EventArgs e) 
    {    
        RadGrid1.MasterTableView.HierarchyDefaultExpanded = true
        RadGrid1.Rebind();       
        RadGrid1.MasterTableView.GetColumn("AutoGeneratedEditColumn").Visible = false
        RadGrid1.MasterTableView.GetColumn("AutoGeneratedDeleteColumn").Visible = false
        foreach (GridDataItem dataitem in RadGrid1.Items) 
        { 
            if (dataitem.Expanded) 
            { 
                dataitem.ChildItem.NestedTableViews[0].GetColumn("AutoGeneratedEditColumn").Visible = false
                dataitem.ChildItem.NestedTableViews[0].GetColumn("AutoGeneratedDeleteColumn").Visible = false;                 
            } 
        } 
        RadGrid1.ExportSettings.ExportOnlyData = false
        RadGrid1.ExportSettings.OpenInNewWindow = true
        RadGrid1.MasterTableView.ExportToExcel(); 
    } 

Thanks
Princy.
Tags
Grid
Asked by
sudheer
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Share this question
or