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

Problems with radgrid export buttons

3 Answers 112 Views
Grid
This is a migrated thread and some comments may be shown as answers.
BizData
Top achievements
Rank 1
BizData asked on 10 Jun 2011, 08:17 AM
Hi,

I have a problem with radgrid export command item buttons. My setup is as follows;

I have a user control within a sharepoint web part. In that user control are multiple rad grids (some housed within child user controls). Each radgrid sits within an ASP.NET update panel. Initially my issue was that while these grids were within an ASP.NET update panel, the export buttons would not work, which was fine as I understood why.

To solve this I added an event handler for the OnItemCreated event of each radgrid. Below is the code for the event handler;

protected void rgv_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridCommandItem)
            {
                Button btncmd = (e.Item as GridCommandItem).FindControl("ExportToExcelButton") as Button;
                if (btncmd != null) { RadScriptManager.GetCurrent(this.Page).RegisterPostBackControl(btncmd); }
  
                btncmd = (e.Item as GridCommandItem).FindControl("ExportToWordButton") as Button;
                if (btncmd != null) { RadScriptManager.GetCurrent(this.Page).RegisterPostBackControl(btncmd); }
  
                btncmd = (e.Item as GridCommandItem).FindControl("ExportToCsvButton") as Button;
                if (btncmd != null) { RadScriptManager.GetCurrent(this.Page).RegisterPostBackControl(btncmd); }
            }
        }

While testing this code change outside of SharePoint (standard asp.net website under IIS7), this worked just fine, I could export to excel as intended, and everything else within the update panel was still working correctly with respect to ajax.

As soon as I published this out to my sharepoint environment (SharePoint 2010 SP1) to test, I ran into an issue. Export to excel still worked just fine, but after using any of the export buttons to download a document, I could no longer interact with the application, in that nothing on the web part would post back anymore (I have a number of rad combo boxes, toolbars etc both within the update panels and outside of the update panels).

I used the same markup for a rad script manager in both the non sharepoint test website and in the sharepoint masterpage of the site hosting the web part.

<telerik:RadScriptManager id="ScriptManager" runat="server" EnablePageMethods="false" EnablePartialRendering="true" EnableScriptGlobalization="false" EnableScriptLocalization="true" ScriptMode="Release"/>

Do you have any ideas why this might be? Or potential work arounds? At the moment its not feasible to change from the current method of using ASP.NET update panels to telerik ajax controls without significant reworking of the application (which is quite large). So any work arounds would be much appreciated.

Thanks

3 Answers, 1 is accepted

Sort by
0
BizData
Top achievements
Rank 1
answered on 12 Jun 2011, 01:57 AM
Hi,

Has anyone had a chance to look at this?

Thanks.
0
Daniel
Telerik team
answered on 13 Jun 2011, 12:56 PM
Hello Mark,

I would recommend that you try to cancel the ajax requests with client script. Here is a sample code:
Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(initializeRequestHandler);
function initializeRequestHandler(sender, args)
{
    var targetId = "Export"; //this will cover all cases - ExportToExcelButton, ExportToWordButton, etc
    if (args.get_postBackElement().id.indexOf(targetId) != -1)
    {
        args.set_cancel(true);
        sender._form["__EVENTTARGET"].value = args.get_postBackElement().id.replace(/\_/g, "$");
        sender._form["__EVENTARGUMENT"].value = "";
        sender._form.submit();
        return;
    }
}

A possible approach is to register this as a startup script through the scriptmanager.

I hope this helps.

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
BizData
Top achievements
Rank 1
answered on 14 Jun 2011, 12:09 AM
Hi Daniel,

After finding out that the issue within SharePoint was not actually related to ajax (just radgrid in general), I was able to find an answer from another thread in this forum. I added the below javascript to my web part and no longer have an issue.

_spBodyOnLoadFunctionNames.push("supressSubmitWraper");
  function supressSubmitWraper() {
      _spSuppressFormOnSubmitWrapper = true;
  }
Tags
Grid
Asked by
BizData
Top achievements
Rank 1
Answers by
BizData
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or