I have a couple fields that are notes fields that i do not put into my radgrid, but when I export I need to go and get them asn export them as well. Is there a way to export the radgrids needdatasource?
<CommandItemTemplate> <table width="100%"> <tr> <td align="right"><asp:Button ID="btnExport" runat="server" CommandName="ExportToExcel" Text="Export Excel" /></td> </tr> </table> </CommandItemTemplate>5 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 09 Apr 2012, 06:58 AM
Hello Kevin,
Try the following code.
C#:
Thanks,
Princy.
Try the following code.
C#:
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e){ if (e.CommandName == "ExportToExcel") { RadGrid1.MasterTableView.GetColumn("UniqueName").Display = true; RadGrid1.ExportSettings.ExportOnlyData = true; RadGrid1.MasterTableView.ExportToExcel(); }}Thanks,
Princy.
0
Kevin
Top achievements
Rank 1
answered on 10 Apr 2012, 02:12 PM
Hi,
This did not work for me, I was under the understanding that if you make something invisible to start it does not render on the page at all. I tried the suggestion but it does not work the field did not export. Is there a way to rebind the datasouce before export in this situation.
<telerik:RadGrid ID="myRadGrid" runat="server" Width="98%" BorderWidth="1px" CellPadding="6" GridLines="None" BorderColor="#404040" Skin="Web20"> <ExportSettings ExportOnlyData="true" FileName="DonorSlots" IgnorePaging="true" OpenInNewWindow="true"></ExportSettings> <MasterTableView AutoGenerateColumns="false" Name="MasterGrid" BorderColor="#404040" Font-Size="9" Font-Names="Veranda,arial,sans-serif" HeaderStyle-HorizontalAlign="Center" GridLines="Both" BorderWidth="1px" CommandItemDisplay="Top" EditMode="EditForms"> <CommandItemSettings ShowAddNewRecordButton="false" ShowRefreshButton="false" ShowExportToExcelButton="false" /><AlternatingItemStyle BackColor="#B0C4DE" HorizontalAlign="Center" /> <ItemStyle HorizontalAlign="Center" /><HeaderStyle ForeColor="White" Font-Bold="true" BorderColor="#404040" BorderWidth="1px" /> <CommandItemTemplate> <table width="100%"> <tr> <td align="right"><asp:Button ID="btnExport" runat="server" CommandName="ExportToExcel" Text="Export Excel" /></td> </tr> </table> </CommandItemTemplate> <Columns> <telerik:GridBoundColumn DataField="Unit" HeaderText="Unit" /> <telerik:GridBoundColumn DataField="Para\Line\Pos" HeaderText="Para\Line\Pos" /> <telerik:GridBoundColumn DataField="Posn_title" HeaderText="Posn_Title" /> <telerik:GridBoundColumn DataField="Name" HeaderText="Name" /> <telerik:GridBoundColumn DataField="Rank" HeaderText="Rank" /> <telerik:GridBoundColumn DataField="SSN" HeaderText="SSN" UniqueName="SSN" Visible="false" /> <telerik:GridBoundColumn DataField="Grade" HeaderText="Grade" /> <telerik:GridBoundColumn DataField="DMOS" HeaderText="Duty_Posn" /> <telerik:GridBoundColumn DataField="REQCLR" HeaderText="Req Clr" /> <telerik:GridBoundColumn DataField="PassPortDT" HeaderText="Pass_Port_DT" /> <telerik:GridBoundColumn DataField="MobDay" HeaderText="Mob Days Cottad" /> <telerik:GridBoundColumn DataField="SCTYDT" HeaderText="Scty_Dt" /> <telerik:GridBoundColumn DataField="PHY_EXAM_DT" HeaderText="Phy_Exam_DT" /> <telerik:GridBoundColumn DataField="MRD\ETS" HeaderText="Ets\Mrd" /> <telerik:GridBoundColumn DataField="SRP_DT" HeaderText="Srp_DT" /> <telerik:GridBoundColumn DataField="CLS" HeaderText="Cls Trained" /> <telerik:GridBoundColumn DataField="Profile" HeaderText="P3\P4 Profile" /> <telerik:GridBoundColumn DataField="Cleared" HeaderText="Mmrp|Peb|Meb Cleared" /> <telerik:GridBoundColumn DataField="Remarks" HeaderText="Remarks" /> </Columns> </MasterTableView> </telerik:RadGrid>
Protected Sub myRadGrid_ItemCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles myRadGrid.ItemCommand
If (e.CommandName = "ExportToExcel") Then
myRadGrid.MasterTableView.GetColumn("SSN").Display = True
myRadGrid.ExportSettings.ExportOnlyData = True
myRadGrid.MasterTableView.ExportToExcel()
End If
End Sub
0
Jayesh Goyani
Top achievements
Rank 2
answered on 10 Apr 2012, 02:25 PM
Hello Kevin,
Thanks,
Jayesh Goyani
If (e.CommandName = "ExportToExcel") Then myRadGrid.MasterTableView.GetColumn("SSN").Display = True myRadGrid.ExportSettings.ExportOnlyData = True myRadGrid.MasterTableView.ExportToExcel() // bind your GRID heremyRadGrid.DataSource = "Yourdatasource"myRadGrid.DataBind() End IfThanks,
Jayesh Goyani
0
Accepted
Princy
Top achievements
Rank 2
answered on 10 Apr 2012, 02:28 PM
Hello Kevin,
One suggestion is you can set Display property of BoundColumn as false and then export the column.
aspx:
Thanks,
Princy.
One suggestion is you can set Display property of BoundColumn as false and then export the column.
aspx:
<telerik:GridBoundColumn DataField="SSN" HeaderText="SSN" UniqueName="SSN" Display="false" />Thanks,
Princy.
0
Kevin
Top achievements
Rank 1
answered on 10 Apr 2012, 02:39 PM
HI,
Ok i see there is a big difference between display and visible. thanks for the info and help.
Ok i see there is a big difference between display and visible. thanks for the info and help.