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

RadGrid export extra data

4 Answers 74 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 03 Feb 2009, 10:39 PM

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

Sort by
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:
 <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
0
Accepted
Daniel
Telerik team
answered on 04 Feb 2009, 08:07 AM
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.
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
Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Paul
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or