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

Custom Export on PreRender

0 Answers 94 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Philip
Top achievements
Rank 1
Philip asked on 11 Jul 2012, 03:23 PM
I'm currently trying to export my Grid when the filters / sorting have been applied.  After reading around, it seems that I can't get that filtered / sorted data back unless in a function like PreRender.  There I can manually loop through each item in the grid and stuff them into an object to send to my custom export utility.

I have a custom javascript button that is running a custom fireCommand which triggers the ItemCommand function to fire off. Following the ideas from this post: http://www.telerik.com/community/forums/aspnet/grid/how-to-get-filter-data.aspx I am setting a flag in the fireCommand when my CommandName is matches the proper condition.  Then in PreRender, I call my own export function when the flag is true and this is where I'm running into issues.  Event Viewer kicks back: Server cannot set content type after HTTP headers have been sent.  

Essentially this is what my custom export function is doing to serve up the file: 
Response.Clear();
Response.AddHeader("Content-Type", "application/pdf");
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName + ".pdf" + ";);
Response.Flush();
Response.BinaryWrite(downloadBytes);
Response.Flush();
Response.End(); 

So is there a way I can access the sorted / filtered data to use in an export of my own?  Or is there any way to suppress whatever is firing off with Http Headers?


No answers yet. Maybe you can help?

Tags
Grid
Asked by
Philip
Top achievements
Rank 1
Share this question
or