12 Answers, 1 is accepted
Check whether you have set the ExportOnlyData property as 'true' which in turn excludes the controls from the exported file. If so set it as 'false' and check if it works now.
ASPX:
<
ExportSettings
ExportOnlyData
=
"false"
></
ExportSettings
>
-Shinu.
You can export the pager item if ExportOnlyData is set to false. Best results can be achieved when PagerMode is set to Slider because you will get plain text only.
<
ExportSettings
ExportOnlyData
=
"false"
/>
<
PagerStyle
Mode
=
"Slider"
/>
Regards,
Daniel
the Telerik team
My problem has no in the Excel file but in the ASP page.
My pager disappears in the ASP page after exporting and do not disappears in the Excel file.
My Exporting is correct, it is page that behaves strange.
Can you help me?
Regards
Thanks
Could you please post your code in this thread? I would like to examine you approach, if possible.
Best regards,
Daniel
the Telerik team
This is the asp page, my radgrid is inside a radajaxpanel.
01.
<
telerik:RadAjaxPanel
ID
=
"panelRGricerca"
runat
=
"server"
>
02.
<
table
id
=
"tblDati"
runat
=
"server"
width
=
"99%"
height
=
"90%"
align
=
"center"
>
03.
<
tr
>
04.
<
td
width
=
"10"
>
05.
06.
</
td
>
07.
<
td
valign
=
"top"
>
08.
<
div
style
=
"overflow: auto; height: 100%; width: 100%;"
id
=
"divRicerca"
>
09.
<
telerik:RadGrid
ID
=
"grdRicerca"
runat
=
"server"
Skin
=
"Default"
AutoGenerateColumns
=
"false"
10.
EnableViewState
=
"true"
AllowPaging
=
"true"
OnNeedDataSource
=
"grdRicerca_OnNeedDataSource"
11.
Width
=
"99%"
AllowSorting
=
"true"
>
12.
<
PagerStyle
AlwaysVisible
=
"false"
Mode
=
"NumericPages"
ShowPagerText
=
"false"
/>
13.
<
ExportSettings
IgnorePaging
=
"true"
OpenInNewWindow
=
"true"
ExportOnlyData
=
"true"
>
14.
<
Pdf
PageBottomMargin
=
"1cm"
PageLeftMargin
=
"1cm"
PageRightMargin
=
"1cm"
PageTopMargin
=
"1cm"
15.
PageWidth
=
"297mm"
PageHeight
=
"210mm"
FontType
=
"Subset"
/>
16.
</
ExportSettings
>
17.
<
MasterTableView
PageSize
=
"10"
EnableViewState
=
"true"
AllowPaging
=
"true"
AllowSorting
=
"true"
18.
ShowHeadersWhenNoRecords
=
"false"
CommandItemDisplay
=
"Top"
>
19.
<
NoRecordsTemplate
>
20.
<
asp:Image
runat
=
"server"
ID
=
"imgNoRecord"
ImageUrl
=
"images/__banner.jpg"
/>
21.
<
br
/>
22.
<
asp:Label
runat
=
"server"
ForeColor
=
"Red"
Font-Bold
=
"true"
ID
=
"noRecord"
Text
=
"Non sono presenti dati con i criteri di ricerca immessi."
></
asp:Label
>
23.
</
NoRecordsTemplate
>
24.
<
Columns
>
25.
<
telerik:GridHyperLinkColumn
HeaderText
=
"Codice UE"
DataTextField
=
"IdUe"
DataTextFormatString
=
"{0}"
26.
DataNavigateUrlFields
=
"IdUe, TipologiaUe"
DataNavigateUrlFormatString
=
"?target=details&args={0},{1}"
>
27.
</
telerik:GridHyperLinkColumn
>
28.
<
telerik:GridBoundColumn
HeaderText
=
"Denominazione"
DataField
=
"Denominazione"
>
29.
</
telerik:GridBoundColumn
>
30.
<
telerik:GridBoundColumn
HeaderText
=
"Descrizione"
DataField
=
"DescrizioneUE"
>
31.
</
telerik:GridBoundColumn
>
32.
<
telerik:GridBoundColumn
HeaderText
=
"Regione"
DataField
=
"REGIONE"
>
33.
</
telerik:GridBoundColumn
>
34.
<
telerik:GridBoundColumn
HeaderText
=
"Provincia"
DataField
=
"PROVINCIA"
>
35.
</
telerik:GridBoundColumn
>
36.
<
telerik:GridBoundColumn
HeaderText
=
"Comune"
DataField
=
"COMUNE"
>
37.
</
telerik:GridBoundColumn
>
38.
<
telerik:GridBoundColumn
HeaderText
=
"Indirizzo"
DataField
=
"Indirizzo"
>
39.
</
telerik:GridBoundColumn
>
40.
<
telerik:GridHyperLinkColumn
ItemStyle-HorizontalAlign
=
"Center"
HeaderText
=
""
DataTextField
=
"IdUe"
41.
DataTextFormatString="<img
height
=
'16'
widhth
=
'16'
src
=
'images/dwf.gif'
border
=
'0'
title
=
'Visualizza in Gestione Spazi'
alt
=
'Planimetria'
/>"
42.
DataNavigateUrlFields="IdUe, TipologiaUe" DataNavigateUrlFormatString="?target=planimetria&args={0},{1}">
43.
</
telerik:GridHyperLinkColumn
>
44.
</
Columns
>
45.
<
CommandItemSettings
ShowExportToExcelButton
=
"true"
ShowRefreshButton
=
"false"
ShowAddNewRecordButton
=
"false"
/>
46.
</
MasterTableView
>
47.
</
telerik:RadGrid
>
48.
</
div
>
49.
</
td
>
50.
<
td
width
=
"10"
>
51.
52.
</
td
>
53.
</
tr
>
54.
</
table
>
55.
</
telerik:RadAjaxPanel
>
This is the javascript function who allow to export in excel, word or pdf format:
1.
function
onRequestStart(sender, args) {
2.
if
(args.get_eventTarget().indexOf(
"ExportToExcelButton"
) >= 0 ||
3.
args.get_eventTarget().indexOf(
"ExportToWordButton"
) >= 0 ||
4.
args.get_eventTarget().indexOf(
"ExportToCsvButton"
) >= 0) {
5.
args.set_enableAjax(
false
);
6.
}
7.
}
In the code behind I'm using the need data source event to bind the data from database.
My problem appears after exported the data and try to click on a control into radgrid.
If I reload the page, the control behaves right.
I'm using RadAjaxManager to update the radajaxpanel when click on a control inside the radgrid.
I think that the problem is during the exporting when I call the method set_enableAjax(false).
Perhaps the control radgrid lose some property during this process...
Best regards.
Thank you for the sample code. I believe the problem is caused due to the fact that you are ajaxifying RadGrid two times. I recommend that you replace the RadAjaxPanel with regular ASP.NET Panel control.
Let me know if the problem still persists.
Kind regards,
Daniel
the Telerik team
Hi,
I've tired to use ASP.NET UpdatePanel and Panel but the problems can not resolve.
During this work I've found a page who doesn't use Panel, and the problem with exporting doesn't disappears.
Now I try to export the data in the server-side.
I don't understand how in your example the pager doesn't disappears, maybe I've wrong anything during the designing step.
Thanks
I attached a sample project that demonstrates how to export RadGrid when residing in ajaxified container. Please test it locally and let me know if I can assist you further.
Below, you can find the code that cancels the AJAX request when exporting:
Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(initializeRequestHandler);
function
initializeRequestHandler(sender, args)
{
if
(args.get_postBackElement().id.indexOf(
"Export"
) != -1)
{
args.set_cancel(
true
);
sender._form[
"__EVENTTARGET"
].value = args.get_postBackElement().id.replace(/\_/g,
"$"
);
sender._form[
"__EVENTARGUMENT"
].value =
""
;
sender._form.submit();
return
;
}
}
Regards,
Daniel
the Telerik team
Thanks,
Ibsa
I hope to help you. (It's been a long time)
the solution is the following function:
/ / Handle the ajax request generated inside a RadAjaxPanel
OnRequestStart
function
(sender, args) {
/ / Blocking asynchronous requests and force a full postback
if
(args.get_eventTarget (). indexOf (
"ExportToExcelButton"
)! = -1 | |
args.get_eventTarget (). indexOf (
"ExportToWordButton"
)! = -1 | |
args.get_eventTarget (). indexOf (
"ExportToCsvButton"
)! = -1 | |
args.get_eventTarget (). indexOf (
"ExportToPdfButton"
)! = -1
)
{
args.set_enableAjax (
false
);
}
}
<telerik:RadAjaxManager ID=
"ajaxManager"
runat=
"server"
>
<ClientEvents OnRequestStart=
"OnRequestStart"
/>
</telerik:RadAjaxManager>
Lasly.
Hello
I'm having a similar issue.
My RadGrid is in an asp panel, within a content page, which at the same time is within a master page. Unfortunately, whenever i click on the ExportToCsvButton, the csv is working and downloading properly, but at the end a _blank page is being shown and no more than that.
Have already implemented the set_enableAjax(false) solution, but is not working. Hope you may help me out with this.
Best Regards