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

Export To Excel

4 Answers 115 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
KE
Top achievements
Rank 1
KE asked on 25 Feb 2014, 11:25 AM
We follow the steps here:
http://demos.telerik.com/aspnet-ajax/pivotgrid/examples/exporting/defaultcs.aspx

But the pivotgrid.exporttoexcel() is not working. We create a button to call this function but there is no file generated as shown in the demo.

Are we missing anything here?

We are using Telerik.Web.UI version 2013.3.1324.40

attach is the code.

4 Answers, 1 is accepted

Sort by
0
KE
Top achievements
Rank 1
answered on 25 Feb 2014, 11:27 AM
0
Matthias
Top achievements
Rank 1
answered on 26 Feb 2014, 03:40 PM
We experience the same problem. We do the ExportToExcel call and nothing happens.
Our code is also very similar to the demo linked above.
0
Accepted
Daniel
Telerik team
answered on 27 Feb 2014, 03:27 PM
Hi guys,

The problem is most probably caused by the fact that the control triggering the export has been ajaxified.
For more information please see here:
Export from Ajaxified Grid

Approach 1 (Telerik RadAjaxManager/RadAjaxPanel dependent)
function onRequestStart(sender, args)
{
  if (args.get_eventTarget().indexOf("btnExport") >= 0)
    args.set_enableAjax(false);
}

In this case you have to wire the handler like this:
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" ClientEvents-OnRequestStart="onRequestStart" ...

or this:
<telerik:RadAjaxManager ID="RadAjaxManager11" runat="server">
    <ClientEvents OnRequestStart="onRequestStart" ...


Approach 2 - this will work with both the regular ASP.NET UpdatePanel and our AJAX controls:
<script type="text/javascript">
    Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(initRequest);
    function initRequest(sender, args)
    {
        if (args.get_postBackElement().id.indexOf("btnExport") != -1)
        {
            args.set_cancel(true);  //stop async request
            sender._form["__EVENTTARGET"].value = args.get_postBackElement().id.replace(/\_/g, "$");
            sender._form["__EVENTARGUMENT"].value = "";
            sender._form.submit();
            return;
        }
    }
</script>


Regards,
Daniel
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
0
KE
Top achievements
Rank 1
answered on 28 Feb 2014, 04:19 AM
Hi Daniel,

It is resolved now, it was mistake on my side :), my javascript onrequeststart is implemented but I forget to add another indexof to look for the id:btnExport. It is already looking for ExportTo for RadGrid.

The javascript code should be like this any new btn that trigger export.

function onRequestStart(sender, args) {
if (args.get_eventTarget().indexOf("ExportTo") >= 0) {
args.set_enableAjax(false);
} else {
args.set_enableAjax(true);
}
if (args.get_eventTarget().indexOf("btnExport") >= 0) {
args.set_enableAjax(false);
} else {
args.set_enableAjax(true);
}
}


Hope this will help anyone.


Thanks
Tags
PivotGrid
Asked by
KE
Top achievements
Rank 1
Answers by
KE
Top achievements
Rank 1
Matthias
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or