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

RadGrid Export to Excel missing columns

4 Answers 195 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John Cooney
Top achievements
Rank 1
John Cooney asked on 20 Jun 2012, 09:45 PM
I have a RadGrid deployed and I am adding in the Export to Excel capability.

Works fine except for one problem.

Previously I had to create a column of type GridButtonColumnWithFilteringSorting as per one of your other support threads and that worked fine for the purpose it was intended.

Now the problem I face is that the column of type GridButtonColumnWithFilteringSorting does not appear in the Excel export file.  The column is present and the header shows up but all of the data is blank.

Thanks for any help.

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Jun 2012, 04:20 AM
Hello John,

I suppose you are setting ExportOnlyData as true when exporting. In order to export the button column, try setting ExportOnlyData as false. Hope this helps.

Thanks,
Shinu.
0
John Cooney
Top achievements
Rank 1
answered on 21 Jun 2012, 01:22 PM
Thank you for the attention.

Yes that addresses the problem but I prefer the formatting in the output file with ExportOnlyData as true.

Let me pose this question in another manner.

Could I carry additional fields in my grid definition as visible = "false" and then intercept the process when the user has clicked Export to Excel button and turn off fields I don't want and turn on fields I do want?

For instance I could essentially have two columns containing this field I mentioned in the original post, one which is type GridButtonColumnWithFilteringSorting set to visible = "true" and second of just GridBoundColumn set to visible = "false".  Then I reset which columns the Export to Excel function is looking at.  So the displaying grid is one set of columns and the export is another set of columns but they are all bound into the grid.
0
John Cooney
Top achievements
Rank 1
answered on 25 Jun 2012, 04:15 PM
Yes / No / Maybe???

I'm not sure if you can do this the way I have proposed in last email.

Thanks for any help!
0
Shinu
Top achievements
Rank 2
answered on 14 Aug 2012, 11:11 AM
Hi,

I suppose you want to export hidden columns in radgrid when exporting. Here is the sample code that I tried.
aspx:
<telerik:RadGrid   ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server" AutoGenerateColumns="False">
 <MasterTableView>
   <Columns>
     <telerik:GridBoundColumn DataField="EmployeeID"  HeaderText="EmployeeID" UniqueName="EmployeeID" />
     <telerik:GridBoundColumn DataField="LastName" Display="false" HeaderText="LastName" UniqueName="LastName"/>
   </Columns>
 </MasterTableView>
</telerik:RadGrid>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
C#:
protected void Button1_Click(object sender, EventArgs e)
{
        RadGrid1.MasterTableView.GetColumn("LastName").Display = true;
        RadGrid1.MasterTableView.ExportToExcel();
}

Thanks,
Shinu.
Tags
Grid
Asked by
John Cooney
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
John Cooney
Top achievements
Rank 1
Share this question
or