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

Export to Excel complicated

2 Answers 70 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Scott Durrett
Top achievements
Rank 1
Scott Durrett asked on 08 Sep 2010, 03:19 PM
I have a simple RadGrid that I need to export to Excel.  I've tried many methods found online but none have worked for me.  here is what I have.

1. Master Page contains Microsoft ScriptManager control.
2. Content Page contains Update Panel control.
3. Grid is setup to export

I know the problem exist around Ajax.  If i remove the update panel from my content form the Export works perfect, however, with the update panel (which I need) the grid just refreshes and looses formatting when I click the export button.

Anyone know how to fix this with Master/Content pages?

Thanks in advance,
Scott

2 Answers, 1 is accepted

Sort by
0
Scott Durrett
Top achievements
Rank 1
answered on 08 Sep 2010, 04:01 PM
Well i was able to fix the export function using the Trigger!  it works now, HOWEVER, when I click the export button, I get the prompt and excel appears.  When i close excel i'm still on the same grid and the format of the grid is all messed up.  My columns are out of align. 

Any ideas with that?
0
Daniel
Telerik team
answered on 13 Sep 2010, 02:44 PM
Hello Scott,

You could cancel the AJAX request on the client (similar to the approach, demonstrated in this topic) with JavaScript code:
Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(initializeRequestHandler);
function initializeRequestHandler(sender, args)
{
    if (args.get_postBackElement().id.indexOf("MY_EXPORT_BUTTON_ID") != -1)
    {
        args.set_cancel(true);
        sender._form["__EVENTTARGET"].value = args.get_postBackElement().id.replace(/\_/g, "$");
        sender._form["__EVENTARGUMENT"].value = "";
        sender._form.submit();
        return;
    }
}

As to the second problem - can you please help me to reproduce it? If you paste the relevant code here, (please use the Format Code Block tool) I will try to create a runnable demo out of it.

Regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Scott Durrett
Top achievements
Rank 1
Answers by
Scott Durrett
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or