I have 2 buttons setup to export to CSV and XLS respectively. I used this example as a basis but when i click the buttons, nothing happens. The code is hit but nothing appears. My code is:
public
void
ConfigureExport()
{
radgrdResultDetail.ExportSettings.ExportOnlyData =
true
;
radgrdResultDetail.ExportSettings.IgnorePaging =
false
;
radgrdResultDetail.ExportSettings.OpenInNewWindow =
false
;
}
protected
void
xlsExport_Click(
object
sender, EventArgs e)
{
ConfigureExport();
radgrdResultDetail.MasterTableView.ExportToCSV();
}
protected
void
csvExport_Click(
object
sender, EventArgs e)
{
ConfigureExport();
radgrdResultDetail.MasterTableView.ExportToExcel();
}
6 Answers, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 17 Apr 2012, 11:05 AM
Hi Michael,
I tried with the code you given and it is working fine at my end.If you are Ajaxifying the RadGrid ,the exporting feature of the control work with regular postbacks only. To bypass the limitation you can wire the OnRequestStart event of the ajax panel or ajax manager, determine whether the target control is ajaxified and explicitly disable its ajax mode to export with regular postback.
ASPX:
Javascript:
Thanks,
Shinu.
I tried with the code you given and it is working fine at my end.If you are Ajaxifying the RadGrid ,the exporting feature of the control work with regular postbacks only. To bypass the limitation you can wire the OnRequestStart event of the ajax panel or ajax manager, determine whether the target control is ajaxified and explicitly disable its ajax mode to export with regular postback.
ASPX:
<
telerik:RadAjaxManager
ClientEvents-OnRequestStart
=
"onRequestStart"
ID
=
"ajax"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadGrid1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
Javascript:
<script type=
"text/javascript"
>
function
onRequestStart(sender, args)
{
if
(args.get_eventTarget().indexOf(
"xlsExport"
) >= 0)
args.set_enableAjax(
false
);
}
</script>
Thanks,
Shinu.
0

Michael
Top achievements
Rank 1
answered on 17 Apr 2012, 11:14 AM
Excellent Shinu, that worked for me :)
0

Michael
Top achievements
Rank 1
answered on 17 Apr 2012, 11:30 AM
One problem, my grid is in edit mode for batch updates. I have a dropdown column and in the export all the options are populated in the excel file, how do i get around this?
0

Michael
Top achievements
Rank 1
answered on 17 Apr 2012, 12:05 PM
Also, the csv, only the grid headers are present. i have set exportonlydata to false for csv export but it still persists. Any help with this would be greatly appreciated.
0

Michael
Top achievements
Rank 1
answered on 17 Apr 2012, 01:52 PM
Any ideas on this?
0

Shinu
Top achievements
Rank 2
answered on 18 Apr 2012, 10:28 AM
Hi Michael,
In order to avoid the issue for exporting to excel you can set the ExportOnlyData to true and for Csv exporting make the entire Grid into normal mode. Please take a look into following code snippet.
C#:
Thanks,
Shinu.
In order to avoid the issue for exporting to excel you can set the ExportOnlyData to true and for Csv exporting make the entire Grid into normal mode. Please take a look into following code snippet.
C#:
protected
void
csvExport_Click(
object
sender, EventArgs e)
{
ConfigureExport();
foreach
(GridDataItem item
in
radgrdResultDetail.Items)
{
item.Edit =
false
;
}
radgrdResultDetail.Rebind();
radgrdResultDetail.MasterTableView.ExportToCSV();
}
Thanks,
Shinu.