We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Exporting Excel File from Grid with AsyncPostBack Trigger in Update Panel

Hi,

I currently have a grid within an UpdatePanel element. In order to update the row(s)/database I have said grid linked to a AsyncPostBack Trigger. Is there any way I could export an excel/pdf file without the "isLocalSave" property or using the PostBack Trigger, since the AsyncPostBack only does a partial page reload? 

I would also like to only use Syncfusion elements if possible.

Thanks!

3 Replies

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team June 4, 2019 09:42 AM UTC

Hi Matt, 

Query#:- I have said grid linked to a AsyncPostBack Trigger. Is there any way I could export an excel/pdf file without the "isLocalSave" property or using the PostBack Trigger. 
 
We have checked your query and we have already discussed this requirement “How to export the data when Grid is in update panel” in our Syncfusion knowledge Base. 
 
Also refer to the code example:- 
<asp:UpdatePanel runat="server"> 
<ContentTemplate> 
     <ej:Grid ID="Grid1" runat="server" AllowSorting="True" OnServerWordExporting="FlatGrid_ServerWordExporting" OnServerPdfExporting="FlatGrid_ServerPdfExporting" OnServerExcelExporting="FlatGrid_ServerExcelExporting" AllowPaging="True"> 
            .   .   . 
        </ej:Grid> 
</ContentTemplate> 
   
<Triggers> 
<asp:PostBackTrigger controlid="FlatGrid"/> 
</Triggers> 
</asp:UpdatePanel> 
 
 
Refer to the KB link:- 
 
Please get back to us if you need any further assistance. 
 
Regards, 
Farveen sulthana T 



MB Matt Broich June 4, 2019 02:51 PM UTC

Hi Farveen,

Thank you for the quick response, however, this did not solve my issue. Whenever I click on the "exportExcel" button I receive the following error: 
Uncaught Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: Thread was being aborted.

This error is caused by the Asynchronous PostBack within the update panel. However, I need the AsyncPostBackTrigger in the update panel to update my grid/database. Is there a way to dynamically switch between the PostBackTrigger and AsyncPostBackTrigger depending on which toolbar button you click? As you cannot have both triggers on the same element.

For instance, I have the Update, Cancel, Excel Export, and PDF Export buttons within my grid's toolbar. Would it be possible to switch triggers from being an AsyncPostBackTrigger to a PostBackTrigger on the Excel and PDF Export buttons? And once the Update button is clicked, switch it back to the original state? 

Thanks!


MP Manivannan Padmanaban Syncfusion Team June 5, 2019 12:12 PM UTC

Hi Matt, 

Query: Is there a way to dynamically switch between the PostBackTrigger and AsyncPostBackTrigger depending on which toolbar button you click? 

From the above query, we are able to understand that you want to change the trigger from AsyncPostBackTrigger  to PostBackTrigger. We can able to change the trigger in the code bebind kindly refer the below general link, 

Using the customtoolbar, render the own toolbar item in toolbar. And in the custom toolbar click event call the server end function and then change the trigger based on the above link.  For customToolbar rendering refer the below code example, 

Or you can use the external button click to change the trigger from AsyncPostBackTrigger  to PostBackTrigger before exporting. 

Regards, 
Manivannan Padmanaban. 


Loader.
Live Chat Icon For mobile
Up arrow icon