I'm exporting a radgrid to .csv, which works great, but now I want to add a few columns that are not in the grid (visible at least) to show on the export. I tried setting the extra fields as columns but setting them visible = false then set them to visible = true on the export button select, but have not be successful.
Anyone have any ideas, or suggestions?
Pa
4 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 04 Feb 2009, 04:05 AM
Hello Paul,
You can try out the following code to make a hidden column visible on exporting:
aspx:
cs:
Thanks
Princy.
You can try out the following code to make a hidden column visible on exporting:
aspx:
<telerik:GridBoundColumn Visible="false" DataField="CompanyName" UniqueName="CompanyName" HeaderText="Company Name"></telerik:GridBoundColumn> |
cs:
protected void Button1_Click(object sender, EventArgs e) |
{ |
RadGrid1.MasterTableView.GetColumnSafe("CompanyName").Visible = true; |
RadGrid1.ExportSettings.ExportOnlyData = true; |
RadGrid1.ExportSettings.OpenInNewWindow = true; |
RadGrid1.ExportSettings.IgnorePaging = true; |
RadGrid1.ExportSettings.Csv.ColumnDelimiter = GridCsvDelimiter.Comma; |
RadGrid1.ExportSettings.Csv.RowDelimiter = GridCsvDelimiter.NewLine; |
RadGrid1.MasterTableView.ExportToCSV(); |
} |
Thanks
Princy.
0

Paul
Top achievements
Rank 1
answered on 04 Feb 2009, 05:00 AM
Thanks for the reply Princy.
I was using RadGrid1.MasterTableView.Columns.FindByUniqueName("CompanyName").visible = true, but the rest of the code was the same. I changed over to the GetColumnSafe, but it didn't help. There must be some setting that is causing this not to work, but I don't know what.
I'm going to create a very simple example and see if I can get this to work.
If you have any other ideas, please let me know.
thanks
Paul
I was using RadGrid1.MasterTableView.Columns.FindByUniqueName("CompanyName").visible = true, but the rest of the code was the same. I changed over to the GetColumnSafe, but it didn't help. There must be some setting that is causing this not to work, but I don't know what.
I'm going to create a very simple example and see if I can get this to work.
If you have any other ideas, please let me know.
thanks
Paul
0
Accepted
Hello Paul,
I attached simple, working example to this post. Please test it locally and let us know if you need further assistance.
Kind regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
I attached simple, working example to this post. Please test it locally and let us know if you need further assistance.
Kind regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

Paul
Top achievements
Rank 1
answered on 04 Feb 2009, 06:17 PM
Thanks for the code Daniel,
The .display = true setting did the trick. I was trying to use the .visible and this caused all kinds of problems.
Paul
The .display = true setting did the trick. I was trying to use the .visible and this caused all kinds of problems.
Paul