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

RadGrid export errors when Saving in IE

1 Answer 13 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 01 Oct 2013, 04:10 AM
Hi;

I'm getting the exact same behaviour as detailed in this thread: http://www.telerik.com/community/forums/aspnet-ajax/grid/error-while-exporting-radgrid-data-to-pdf.aspx but only with IE. As in the thread, I'm getting errors exporting to Excel and PDF if I choose Open from the browser's download message.

 I'm running IE9, and tried it with and without compatibility view.  Choosing Save works correctly, and I can open the resulting files with no problem.

I'm using Telerik AJAX Components 2013 Q2 NET 40.

In FireFox, I am able to Open the files without an error.  Here's the relevant code:

The alert in the onRequestStart function returns the client ID, which does contain the button ID's being tested for.
<script type="text/javascript">
    function onRequestStart(sender, args)
    {
        if
        (
            (args.get_eventTarget().indexOf("ExportToExcelButton") >= 0)
            || (args.get_eventTarget().indexOf("ExportToPdfButton") >= 0)
        )
        {
            alert(args.get_eventTarget());
            args.set_enableAjax(false);
        }
    }
 
</script>

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" UpdatePanelsRenderMode="Inline">
    <ClientEvents OnRequestStart="onRequestStart" />
    <AjaxSettings>
.
.
.
        <telerik:AjaxSetting AjaxControlID="ReportResultsGrid">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="ReportResultsGrid" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">
</telerik:RadAjaxLoadingPanel>

<telerik:RadGrid ID="ReportResultsGrid" runat="server" AllowPaging="True" AllowSorting="True"
    Height="100%" Width="98%" CellSpacing="0" GridLines="None" ShowGroupPanel="True"
    OnColumnCreated="ReportResultsGrid_ColumnCreated" AutoGenerateColumns="False"
    OnNeedDataSource="ReportResultsGrid_NeedDataSource" PageSize="20" OnItemCreated="ReportResultsGrid_ItemCreated">
    <ExportSettings OpenInNewWindow="True" ExportOnlyData="True" HideStructureColumns="True"
        IgnorePaging="True">
        <Pdf BorderType="NoBorder" ForceTextWrap="true" PageTopMargin="1.5in" PageBottomMargin="0.5in"
            PageLeftMargin="0.1in" PageRightMargin="0.1in">
        </Pdf>
    </ExportSettings>
    <ClientSettings AllowColumnsReorder="True" AllowDragToGroup="True" ReorderColumnsOnClient="True">
        <Scrolling UseStaticHeaders="True" />
    </ClientSettings>
    <MasterTableView PageSize="25" CommandItemDisplay="TopAndBottom">
        <CommandItemSettings ShowAddNewRecordButton="False" ShowExportToExcelButton="True"
            ShowExportToPdfButton="True" ShowRefreshButton="False" />
        <Columns>
.
.
.
[grid bound columns]
.
.
.
        </Columns>
        <PagerStyle Position="TopAndBottom" AlwaysVisible="true" />
        <CommandItemStyle HorizontalAlign="Left" />
    </MasterTableView>
    <PagerStyle PageSizes="10;25;50;100;200" Position="TopAndBottom" />
</telerik:RadGrid>

Code-behind.  I'm doing custom page sizes and hiding one of the gridBound columns.

protected void ReportResultsGrid_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridPagerItem)
    {
        var dropDown = (RadComboBox)e.Item.FindControl("PageSizeComboBox");
        var totalCount = ((GridPagerItem)e.Item).Paging.DataSourceCount;
        var sizes = new Dictionary<string, string>() {
            {"10", "10"},
            {"25", "25"},
            {"50", "50"}
        };
        if (totalCount > 100)
        {
            sizes.Add("100", "100");
        }
        if (totalCount > 200)
        {
            sizes.Add("200", "200");
        }
        sizes.Add("All", totalCount.ToString());
 
        dropDown.Items.Clear();
        foreach (var size in sizes)
        {
            var cboItem = new RadComboBoxItem() { Text = size.Key, Value = size.Value };
            cboItem.Attributes.Add("ownerTableViewId", e.Item.OwnerTableView.ClientID);
            dropDown.Items.Add(cboItem);
        }
        dropDown.FindItemByValue(e.Item.OwnerTableView.PageSize.ToString()).Selected = true;
    }
}
 
protected void ReportResultsGrid_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
{
    if (e.Column is GridBoundColumn)
    {
        GridBoundColumn col = (GridBoundColumn)e.Column;
        if (col.UniqueName == "ID")
        {
            col.Visible = false;
        }
    }
}
 
protected void ReportResultsGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    DataTable results = (DataTable)Session[ListReportResultsName];
 
    ReportResultsGrid.DataSource = results;
}

Any ideas on what I need to change?

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 04 Oct 2013, 07:30 AM
Hello Thomas,

I examined the provided code and as far as I can see it looks correct. Could you please provide a small runnable sample where the issue could be replicate d in order to investigate the issue further.?

Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Thomas
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or