Export To Excel

5 posts, 1 answers
  1. KE
    KE avatar
    3 posts
    Member since:
    Sep 2011

    Posted 25 Feb 2014 Link to this post

    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.
  2. UI for ASP.NET Ajax is Ready for VS 2017
  3. Matthias
    Matthias avatar
    2 posts
    Member since:
    Feb 2012

    Posted 26 Feb 2014 Link to this post

    We experience the same problem. We do the ExportToExcel call and nothing happens.
    Our code is also very similar to the demo linked above.
  4. Answer
    Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 27 Feb 2014 Link to this post

    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.
  5. KE
    KE avatar
    3 posts
    Member since:
    Sep 2011

    Posted 27 Feb 2014 in reply to Daniel Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017