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

Losing pager after exporting

12 Answers 281 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lasly
Top achievements
Rank 1
Lasly asked on 14 Dec 2010, 10:42 AM
Hi,

I've a problem when try to exporting my radgrid with excel button.
When exporting the data, page loses the pager.

Data was exported successfully.

How can i resolve this problem?

Thanks
Regards

12 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 Dec 2010, 11:32 AM
Hello,

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.

0
Daniel
Telerik team
answered on 14 Dec 2010, 11:58 AM
Hello Martini,

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
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Lasly
Top achievements
Rank 1
answered on 17 Dec 2010, 03:10 PM

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

0
Daniel
Telerik team
answered on 17 Dec 2010, 05:40 PM
Hello Martini,

Could you please post your code in this thread? I would like to examine you approach, if possible.

Best regards,
Daniel
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Lasly
Top achievements
Rank 1
answered on 20 Dec 2010, 09:24 AM
Hello Daniel
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.    &nbsp;
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.    &nbsp;
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.

0
Daniel
Telerik team
answered on 22 Dec 2010, 09:53 PM
Hello Martini,

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
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Lasly
Top achievements
Rank 1
answered on 24 Dec 2010, 10:22 AM

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

0
Accepted
Daniel
Telerik team
answered on 24 Dec 2010, 11:28 AM
Hello Martini,

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
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Ibsa
Top achievements
Rank 1
answered on 30 Jul 2012, 03:38 PM
Hi, Martini, Telerik team, have you found a solution to this issue please? I am having the same exact problem and I can't seem to get it resolved. I downloaded the project file attached at the end if this thread and tried to no avail to get paging/sorting/filtering working once export button is clicked. I am working on an application page on SharePoint 2010 with "RadControls for ASP.NET AJAX Q1 2011" installed. 

Thanks,
Ibsa
0
Lasly
Top achievements
Rank 1
answered on 31 Jul 2012, 08:54 AM
Hi 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);
     }
  
}
you have to call from your RadAjaxManager.     
<telerik:RadAjaxManager ID="ajaxManager" runat="server">
       <ClientEvents OnRequestStart="OnRequestStart" />
   </telerik:RadAjaxManager>
    
if it does not work, let me know .. that we try again together.

Lasly.

0
Ibsa
Top achievements
Rank 1
answered on 31 Jul 2012, 03:40 PM
0
Omar
Top achievements
Rank 1
answered on 13 Nov 2017, 10:15 PM

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

Tags
Grid
Asked by
Lasly
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Daniel
Telerik team
Lasly
Top achievements
Rank 1
Ibsa
Top achievements
Rank 1
Omar
Top achievements
Rank 1
Share this question
or