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

Export with AJAX

2 Answers 226 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 2
Steve asked on 29 Jan 2008, 10:54 PM

My application uses master pages, I have a Prometheus RadGrid on my content page along with an asp:Image control that, when you mouseover it, displays a RadContextMenu with options for exporting grid data (Excel, PDF, etc.).  I have the RadContextMenu controlling the grid via RadAjaxManagerProxy:

<telerik:AjaxSetting AjaxControlID="RadContextMenuExport">
    <UpdatedControls>
        <telerik:AjaxUpdatedControl ControlID="radgRoles" LoadingPanelID="RadAjaxLoadingPanel1" />
    <telerik:AjaxUpdatedControl ControlID="RadContextMenuExport" LoadingPanelID="RadAjaxLoadingPanel1" />
    </UpdatedControls>
</telerik:AjaxSetting>

And I am handling the "AjaxRequestStart" event of the master page RadAjaxManager with the following script (as found on a telerik code library project):

function
OnAjaxManagerRequestStart(ajaxManager, eventArgs)
{
    var arg = eventArgs.EventTarget;

    // If the object initiating this request was an "Export" button (for exporting RadGrid data)
    // cancel the Ajax request so a normal postback occurs. This is required for RadGrid 
    // export functionality to work.
    if (arg.substring(arg.length - 6) == 'Export') eventArgs.EnableAjax = false;
}

It works just fine but, after doing an export, the next time I click to expand/collapse a grouping in my grid, the OnAjaxManagerRequestStart  function continues to recognize the control requesting the AjaxRequest as the RadContextMenu.  As soon as I sort on the grid (or any other action), expand/collapse functionality returns to normal.  Any ideas?

2 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 30 Jan 2008, 04:42 PM
Hi Steve,

We've been unable to reproduce this. Can you modify the bottom project from this code library to show the erroneous behavior and attach it in a support ticket? We will get back to you with more info, once we review it.

Best wishes,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Steve
Top achievements
Rank 2
answered on 30 Jan 2008, 05:50 PM
I found a workaround.  The problem was this: handling of the launching of the export in RadAjaxManager.OnRequestStart sets "EnableAjax=false".  The EventTarget was (correctly) the RadContextMenu.  Then right after that, doing an expand/collapse of a group in the grid, when that ajax request is handled in OnRequestStart, for some reason the EventTarget was still RadContextMenu.  I did the following workaround:

When the user clicks to show the RadContextMenu, I call a function on the master that sets a variable to true indicating that the user has displayed the menu to do an export.  Then, when the user actually clicks an export method to perform the export, the RadAjaxManager.OnRequestStart checks if the EventTarget is the "Export" menu AND if this variable is set to true.  If so, it sets EnableAjax=false and the indicator variable back to false.  If not, EnableAjax set back to true.  So, when doing a RadGrid expand/collapse right after the export, when RadAjaxManager.OnRequestStart is called and it incorrectly recognizes the context menu as the EventTarget, the fact that my variable is not set to true (since the user did not click to show the menu prior to OnRequestStart being called), EnableAjax is set to true and the expand/collapse works how it should.

Might be hard for you guys to understand, but bottom line it works and I need to keep going with my project.  Thanks.
Tags
Grid
Asked by
Steve
Top achievements
Rank 2
Answers by
Steve
Telerik team
Steve
Top achievements
Rank 2
Share this question
or