Telerik
Home / Community / Forums / RadControls for ASP.NET: Grid / Export To Excel Kills Javascript Functionality?

Export To Excel Kills Javascript Functionality?

Feed from this thread
  • darcyl avatar

    Posted on May 14, 2007 (permalink)

    Weird problem trying to export a grid to Excel from within a webpart.

    I have a button that has this code in it:

    ExecuteQuery(); //This just fills the grid again with data
    grdResults.MasterTableView.ExportToExcel2007();

    That's all that happens on the click event. Now, the export itself actually works...i get the file and can open it no problem.

    But for some reason after the file is saved or opened, any other postback attempt is kyboshed on the page. If I try to sort a column in the grid, or if I try to export again, or perform another search to fill my grid, nothing gets posted back.

    Any thoughts on why this might be happening in conjunction with the export?

    Thanks,

    D

    Reply

  • darcyl avatar

    Posted on May 14, 2007 (permalink)

    Just waned to provide an update...

    I noticed that if my page loads and I put my cursor over the Export button I have in my webpart, it displays this in the IE status bar:

    /MyDirectory/MyWebPart/default.aspx

    But after I do the export, putting my mouse over the button gives me this:

    default.aspx

    The whole /MyDirectory/MyWebPart/ piece is gone...

    The plot thickens...

    D

    Reply

  • David Silveria Master avatar

    Posted on May 15, 2007 (permalink)

    ExportToExcel2007() method is obsolete in the latest version of RadGrid. You can upgrade to 4.6, use ExportToExcel() and if still having the same problem - provide some code.

    Reply

  • darcyl avatar

    Posted on May 15, 2007 (permalink)

    K, so I upgraded to the latest version, and the code is now implementing the straight "ExportToExcel()" (btw, ExportToExcel2007 is still listed in intellisense...).

    Same thing is happening: it performs the export, but then the page is fubarred. I also have a line that tries to add text to a label, but that doesn't get executed.

    protected void cmdExport_Click(object sender, System.EventArgs e)
    {
    ExecuteQuery();
    grdResults.MasterTableView.ExportToExcel();
    InfoLabel.Text =
    "cmdExport was executed";
    }
    The last line where the InfoLabel has its text assigned never gets called...but no error is displayed.

    D

    Reply

  • darcyl avatar

    Posted on May 15, 2007 (permalink)

    One other note (shouldn't matter, but just in case...)

    The grid is part of a webpart being deployed to Sharepoint 2007, not just a regular asp.net web page.

    D

    Reply

  • Kevin Master avatar

    Posted on May 15, 2007 (permalink)

    Maybe you can try using the following setting to the exporting functionality of rad grid prior to exporting? This way, the export will be targetted in a new window and this may help alleviate the problem you are having.

    e.g.

    grdResults.ExportSettings.OpenInNewWindow = true;

    By the way, any code after the ExportToExcel() call that deals with rendering logic will appear not to work, since ExportToExcel() actually switches the rendering of the page using SetRenderMethodDelegate - at Render, the exported output is rendered instead of what the page would look like, hence any code after it will appear not to execute.

    Reply

  • darcyl avatar

    Posted on May 15, 2007 (permalink)

    Thanks for the info Kevin...I thought I was losing my mind about why it was stopping rendering after the export, but that explains it.

    I actually do have the OpenInNewWindow=True already set for the grid earlier, but its still kyboshing my postback controls.

    Still need more playing around with it I guess.

    Thanks!

    D'Arcy

    Reply

  • darcyl avatar

    Posted on May 15, 2007 (permalink)

    So what you're telling me is that I'm hooped then...because of something in the way a Web Part is rendered, because of the delegate that the grid utilizes none of my post-back controls are going to render properly?

    D

    Reply

  • surfer Master avatar

    Posted on May 16, 2007 (permalink)

    Changed rendering is used only to export (effectively, download) the file, so I do not believe it is related to the problem... rather, that is something related to the WebPart framework. Are you using Sharepoint WebParts, or plain ASP.NET 2.0 portal webparts?

    Reply

  • darcyl avatar

    Posted on May 16, 2007 (permalink)

    This is for a Sharepoint 2007 web part, not an ASP.NET web part.

    D

    Reply

  • Sonny avatar

    Posted on May 16, 2007 (permalink)

    I am having a similar (if not the same) problem with my DotNetNuke module.  After I call the ExportToExcel() function the spreadsheet opens in a new window.  Then I click on something in my old window (i.e. an edit link in my grid - or something with do_postback) and it works the first time, but immediately stops working.  Alternatively, if I export the spreadsheet, then navigate to the page which originally called my page (which also has a grid in it), the grid also stops working there as well, even though it is a totally different page.

    I have to close and reopen my browser and/or logout and login to my dnn site - but this doesn't always fix the problem.  Sometimes waiting a period of time say 15 seconds, or sometimes 5 minutes, then trying again will fix the page again.  And - to top it all off, this only happens some of the time and not others using the same action on my page.  But one thing I did notice is that it seems to happen more when I am exporting larger grids i.e. 85 items vs smaller grids i.e. 2 items.  Here is the code I am using on the server side:

    Protected Sub btnExport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExport.Click
        rgrdDockReceiptLineItems.ExportSettings.ExportOnlyData = True
        rgrdDockReceiptLineItems.ExportSettings.IgnorePaging = True
        rgrdDockReceiptLineItems.ExportSettings.OpenInNewWindow = True
        rgrdDockReceiptLineItems.MasterTableView.ExportToExcel()
    End Sub

    Reply

  • Johan Master avatar

    Posted on May 17, 2007 (permalink)

    I am not sure, but this may also be related to the following problem (especially if you are using EnableAJAX for the grid and disabling it on export per the Code Library example):

    http://www.telerik.com/community/forums/thread/b311D-tttmh.aspx

    <quote>
    This one seems like a bug in ajax code.  Disabling AJAX in order to export breaks EnablePostBackOnRowClick setting in RadGrid. Our developers have been notified and they will consider it for a fix. One possible workaround would be to exclude the button that triggers the export from AJAX manager's settings. If the button is placed inside a RadGrid item you may consider hooking on the client click event and perform a postback as shown in this help topic.</quote>

    Hopefully there will be a hotfix for this issue soon.

    Reply

  • Sonny avatar

    Posted on May 17, 2007 (permalink)

    I need another solution since my grids don't have AJAX enabled.  But I will say that disabling the use of AJAX on any of my DNN modules has solved the problem most of the time.

    Reply

  • jepper avatar

    Posted on Mar 14, 2008 (permalink)

    Was this ever fixed?

    I have a smilar problem as well

    Reply

  • Telerik Admin admin's avatar

    Posted on Mar 14, 2008 (permalink)

    Hi jepper,

    Please, find attached a page, that shows how you can have RadGrid fully operational (with EnablePostBackOnRowClick working) after export.

    Here is some background. When exporting the __EVENTTARGET is populated by the grid. But there is no response back to the page - the export is saved as a file, so the event target remains. That prevents the grid from making postback/ajax request on row click, the grid checks __EVENTTARGET value before posting back. So, simply clearing it should work. Was your problem related to that?

    Kind regards,
    Ves
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
    Attached files

    Reply

  • jepper avatar

    Posted on Mar 17, 2008 (permalink)

    The solution might be related to what you posted.

    However I belivee that my specific problem is not related to "__EVENTTARGET"

    I trigger my export from a rad-menu outside the grid.

    The menu posts to a hidden field we have made ourselfs ( Customcommand )

    The export works fine but on postbacks done after the export our Customcommand keeps holding the "exportToExcel" parameter.


    Reply

  • Telerik Admin admin's avatar

    Posted on Mar 17, 2008 (permalink)

    Hello jepper,

    Have you switched off the built-in ajax for the grid and refresh the menu, hidden field and the grid itself via RadAjaxManager on the page? This should refresh the hidden field value when you change it explicitly after the export operation is completed. Let me know if I am missing something from your logic.

    Best,
    Stephen
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

    Reply

Powered by Sitefinity ASP.NET CMS

Contact Us | Site Feedback | Terms of Use | Privacy Policy
Copyright © 2002-2009 Telerik. All rights reserved.