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

[Solved] Do not want command/template column headers in RadGrid exported file

2 Answers 130 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Abhishek Parakh
Top achievements
Rank 1
Abhishek Parakh asked on 22 Jun 2009, 01:40 PM
I am exporting RadGrid using the exportToCSV() functionality. I have command fields whose headers I don't want to be exported.

At present the export is like this:
"Notes","View/Edit","First Name","Last Name","Organization","Job Title","Email","Business Phone","Delete"
"","","Abhishek","Parakh","State","Web Dev","yadayada@yahoo.com","405-xxx-xxxx",""

I want it to be like this:
"First Name","Last Name","Organization","Job Title","Email","Business Phone"
"Abhishek","Parakh","State","Web Dev","yadayada@yahoo.com","405-xxx-xxxx"

I dont want to do things manually. For example, do replace or remove characters, I just dont want the command fields to be exported from the radgrid.

Someone has posted examples such as
e.ExportOutput = e.ExportOutput.Replace("<head>", head);                      
e
.ExportOutput = e.ExportOutput.Replace("<td>", "<td class='cell'>")

However, again this is only manual replacements. In future names of my command fields may change as well as their position.

All I want is that radgrid should not export command fields but only the fields corresponding to my database table and data.

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 22 Jun 2009, 02:12 PM
Hello Abhishek,

Try the following:
protected void Button2_Click(object sender, EventArgs e) 
    foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns) 
    { 
        if (col is GridEditCommandColumn) 
            col.Visible = false
    } 
    RadGrid1.MasterTableView.ExportToCSV(); 

or:
protected void Button2_Click(object sender, EventArgs e) 
    RadGrid1.MasterTableView.GetColumn("commandColumn").Visible = false
    RadGrid1.MasterTableView.ExportToCSV(); 

Regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Abhishek Parakh
Top achievements
Rank 1
answered on 22 Jun 2009, 02:43 PM
Thanks a lot. Worked perfectly.
Tags
Grid
Asked by
Abhishek Parakh
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Abhishek Parakh
Top achievements
Rank 1
Share this question
or