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

Export shown in grid

10 Answers 50 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ahrensberg
Top achievements
Rank 1
Ahrensberg asked on 16 Nov 2009, 10:59 AM
Hello all,

I have a grid, whose export functionality has worked well so far. I've made a lot of changes without testing this functionality, but now the export not return an xls/doc file, but instead shows all data in the grid.

I have a lot of code, so before I paste it all here, I would here for any of you have any idea what I could do to solve my problem, and again will receive an xsl/doc file instead.

Best regards,
Kenneth

10 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 16 Nov 2009, 11:31 AM
Hello Ahrensberg,

I'm not sure that I understand the problem completely. I suppose your question is in regard to the internal structure of the Excel (HTML) and Word formats? They both are HTML-based and it is expected that their content is HTML. Am I missing something?

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ahrensberg
Top achievements
Rank 1
answered on 16 Nov 2009, 12:05 PM
My problem is that the content in the grid is shown in another way instead of actually give me an excel file.

See the attachment:
- "have.gif": Is how my grid is look like from the start
- "want.gif": Is what I wish to have, and have got before (by click at my export button)
- "get.gif": Is what I actually get (the grid is updated to this)

EDIT: Something happens with my upload to this forum. The "want.gif" should be "get.gif", and vice versa. I want this "Open/Save/Cancel".
0
Daniel
Telerik team
answered on 18 Nov 2009, 11:55 AM
Hello Ahrensberg,

Please try the following approach:
<telerik:RadGrid ID="RadGrid1" runat="server" ...>
    <ExportSettings OpenInNewWindow="true" ... />

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ahrensberg
Top achievements
Rank 1
answered on 18 Nov 2009, 03:54 PM
When I add the code above I get the following error:

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near 'Telerik.Web.UI 2009.'.

Can the reason be that the grid is placed on a usercontrol? The usercontrol is loaded into the page like shown in example "TabStrip / Load on Demand RadPageView".
0
Princy
Top achievements
Rank 1
answered on 19 Nov 2009, 01:52 PM
Hello Ahrensberg,

Check out the following forum link which discusses on a similar error as yours. Probably it should help:
Error Parsing

Hope this helps..
Princy.
0
Accepted
Daniel
Telerik team
answered on 19 Nov 2009, 03:57 PM
Hello Ahrensberg,

Please download the attached demo and let me know whether it works properly on your end. Note that I disable AJAX explicitly when exporting RadGrid:
function requestStart(sender, args)
{
    if (args.get_eventTarget().indexOf("Button1") >= 0)
        args.set_enableAjax(false);       
}

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ahrensberg
Top achievements
Rank 1
answered on 20 Nov 2009, 01:53 PM
It helped with the:
function requestStart(sender, args)  
{  
    if (args.get_eventTarget().indexOf("Button1") >= 0)  
        args.set_enableAjax(false);          

... and including:
<telerik:AjaxSetting AjaxControlID="Button1"></telerik:AjaxSetting> 

I now only have a problem. I use "window.onbeforeunload" to make some check whether there have been some unsaved changes, but this check must not happen, when this request is called. I can define a "exportIsOngoing" variable to true in my ajaxRequestStart, but how can I set it to false again? Since it no longer is an ajaxrequest I cannot use ajaxRequestEnd.
0
Ahrensberg
Top achievements
Rank 1
answered on 20 Nov 2009, 02:00 PM

[Deleted]

0
Accepted
Daniel
Telerik team
answered on 26 Nov 2009, 03:02 PM
Hello Ahrensberg,

You could try to set your flag on OnRequestStart and then use the OnBeforeUnload event to set it to false again:
<script type="text/javascript">
    var exportflag = false;
    window.onbeforeunload = function()
    {
        alert(exportflag);
        if (exportflag == true)
        {
            exportflag = false;
        }
        else
            //do something
    }
    function requestStart(sender, args)
    {
        if (args.get_eventTarget().indexOf("Button1") >= 0)
        {
            exportflag = true;
            args.set_enableAjax(false);
        }
    }
</script>
 
Regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ahrensberg
Top achievements
Rank 1
answered on 26 Nov 2009, 03:31 PM
Of course! :-P

Thank you... problem solved! :o)
Tags
Grid
Asked by
Ahrensberg
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Ahrensberg
Top achievements
Rank 1
Princy
Top achievements
Rank 1
Share this question
or