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

Export stops working after column sort

10 Answers 114 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 20 Jan 2011, 08:53 PM
Hi, 

I'm using version 2010.2.826.40. 

My RadGrid exports work fine until I do a column sort or group. Then, when trying to export, the entire grid simply re-displays itself in the browser.

Here's my code.

Thanks much,
Dan Cogswell

<asp:EntityDataSource ID="edsEmployees" runat="server" ConnectionString="name=dbIT_Entities"
            DefaultContainerName="dbIT_Entities" EnableDelete="false" EnableInsert="False"
            EnableUpdate="False" EntitySetName="ActivePhoneLists" EnableFlattening="False"
            OrderBy="it.LastName, it.FirstName" />
        <asp:EntityDataSource ID="edsDepartments" runat="server" ConnectionString="name=dbIT_EmployeesEntities"
            DefaultContainerName="dbIT_EmployeesEntities" EntitySetName="Departments" EnableFlattening="False" />
        <telerik:RadGrid ID="rgEmployees" Skin="WebBlue" ShowGroupPanel="True" runat="server" DataSourceID="edsEmployees"
            AllowAutomaticDeletes="False" AllowAutomaticInserts="false" AllowAutomaticUpdates="false"
            AllowSorting="True" AllowFilteringByColumn="true" AutoGenerateColumns="False"
            GridLines="None" PagerStyle-Position="Top" AllowPaging="true" 
            ClientSettings-Scrolling-AllowScroll="false" ShowStatusBar="true" >
            <ClientSettings AllowGroupExpandCollapse="True" ReorderColumnsOnClient="True" AllowDragToGroup="True" AllowColumnsReorder="True">
                <Selecting AllowRowSelect="True" UseClientSelectColumnOnly="True" />
                <Scrolling AllowScroll="True" UseStaticHeaders="True" />
            </ClientSettings>
            <GroupingSettings ShowUnGroupButton="true" />
            <ExportSettings HideStructureColumns="true" ExportOnlyData="true" IgnorePaging="true" 
            Pdf-PageLeftMargin=".5in"
            Pdf-PageRightMargin=".5in" Pdf-PageTitle="CMRP Phonebook" Pdf-PageHeight="8.5in" Pdf-PageWidth="11in"
            OpenInNewWindow="true"></ExportSettings>
            <MasterTableView DataKeyNames="EmployeeNumber" GroupLoadMode="Client" CommandItemDisplay="Top" >
                <CommandItemSettings ShowExportToWordButton="true" ShowExportToExcelButton="true" 
                    ShowExportToCsvButton="true" ShowExportToPdfButton="true" ShowAddNewRecordButton="false" />
                <HeaderStyle HorizontalAlign="Left" />
                <Columns>
                    <telerik:GridBoundColumn ReadOnly="true" DataField="EmployeeNumber" UniqueName="EmployeeNumber"
                        HeaderText="Employee Num" Visible="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="LastName" HeaderText="Last Name" ItemStyle-Width="80px"
                        HeaderStyle-Width="80px" FilterControlWidth="50px">
                        <HeaderStyle Width="80px" />
                        <ItemStyle Width="80px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="FirstName" HeaderText="First Name" ItemStyle-Width="80px"
                        HeaderStyle-Width="80px" FilterControlWidth="50px">
                        <HeaderStyle Width="80px" />
                        <ItemStyle Width="80px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Phone" HeaderText="Phone" ItemStyle-Width="90px"
                        HeaderStyle-Width="90px" FilterControlWidth="50px">
                        <HeaderStyle Width="90px" />
                        <ItemStyle Width="90px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn UniqueName="DeptId" DataField="DeptId" HeaderText="Dept"
                        ItemStyle-Width="60px" HeaderStyle-Width="80px" FilterControlWidth="60px">
                        <FilterTemplate>
                            <telerik:RadComboBox ID="rcbDepartment" DataSourceID="edsDepartments" DataTextField="DeptId"
                                DataValueField="DeptId" AppendDataBoundItems="true" 
                                SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("DeptId").CurrentFilterValue %>'
                                runat="server" OnClientSelectedIndexChanged="DepartmentIndexChanged" Width="60px">
                                <Items>
                                    <telerik:RadComboBoxItem Text="All" />
                                </Items>
                            </telerik:RadComboBox>
                            <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                                <script type="text/javascript">
                                    function DepartmentIndexChanged(sender, args) {
                                        var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                        tableView.filter("DeptId", args.get_item().get_value(), "EqualTo");
                                    }
                                </script>
                            </telerik:RadScriptBlock>
                        </FilterTemplate>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Title" HeaderText="Title" MaxLength="250" ItemStyle-Width="150px"
                        HeaderStyle-Width="150px" FilterControlWidth="110px" ItemStyle-Wrap="false">
                        <HeaderStyle Width="150px" />
                        <ItemStyle Width="150px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Building" HeaderText="Building" ItemStyle-Width="125px"
                        HeaderStyle-Width="125px" FilterControlWidth="85px" ItemStyle-Wrap="false">
                        <HeaderStyle Width="125px" />
                        <ItemStyle Width="125px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Room" HeaderText="Room" ItemStyle-Width="100px"
                        HeaderStyle-Width="100px" FilterControlWidth="60px" ItemStyle-Wrap="false">
                        <HeaderStyle Width="100px" />
                        <ItemStyle Width="100px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="CellPhone" HeaderText="CellPhone" ItemStyle-Width="90px"
                        HeaderStyle-Width="90px" FilterControlWidth="50px">
                        <HeaderStyle Width="90px" />
                        <ItemStyle Width="90px" />
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>

10 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 20 Jan 2011, 11:22 PM
Hello Dan,

Do you use AJAX? And if so, could you please post some more information about your AJAX setup so that I try to provide straight-to-the-point recommendation for you?

Best regards,
Daniel
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Dan
Top achievements
Rank 1
answered on 21 Jan 2011, 01:59 PM
Hi, Daniel.

Yes, I've got the following AJAX:

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <ClientEvents OnRequestStart="onRequestStart" />
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rgEmployees">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgEmployees" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <script type="text/javascript">
        function onRequestStart(sender, args) {
            if (args.get_eventTarget().indexOf("ExportToExcelButton") >= 0 ||
                    args.get_eventTarget().indexOf("ExportToWordButton") >= 0 ||
                    args.get_eventTarget().indexOf("ExportToPdf") >= 0 ||
                    args.get_eventTarget().indexOf("ExportToCsvButton") >= 0) {
                args.set_enableAjax(false);
            }
        }
    </script>

I just deleted that code and it seems to be working now. I can sort and group on columns and the export still works.

Thanks!

Dan
0
Daniel
Telerik team
answered on 21 Jan 2011, 06:12 PM
Hello Dan,

I asked you about your AJAX setup since this may happen in different scenarios. For example, if you try to disable AJAX with RegisterPostBackControl method or if the export initiator control is ajaxified more than once.

Let me know if I can assist you further.

Best regards,
Daniel
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Dan
Top achievements
Rank 1
answered on 24 Jan 2011, 04:47 PM
Hi, Daniel.

I just use the RadAjaxManager:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <ClientEvents OnRequestStart="onRequestStart" />
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rgEmployees">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgEmployees" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

When I take it out, the export stops working (instead of exporting the grid is displayed on the screen). But of course, the grid is no longer ajax enabled. I do not use RegisterPostBackControl to disable AJAX.

So, I guess it's still a problem if I want to keep the grid ajaxified.

Thanks,
Dan


0
Daniel
Telerik team
answered on 24 Jan 2011, 08:54 PM
Hello Dan,

Could you please attach the relevant pages (as ZIP or RAR) to a regular support ticket? I would like to examine it locally, if you don't mind.

Regards,
Daniel
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Dan
Top achievements
Rank 1
answered on 24 Jan 2011, 10:07 PM
Daniel,

I think my capability of creating support tickets stopped after 90 days.

Anyway, I stripped everything out including all code behind, references to a master page and datasources, and I'm left with just the following in my aspx file:

<%@ Page Language="C#" AutoEventWireup="true"  %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxToolkit" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <ClientEvents OnRequestStart="onRequestStart" />
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rgEmployees">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgEmployees" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <div>
        <asp:EntityDataSource ID="edsEmployees" runat="server" ConnectionString="name=dbA_EmployeesEntities"
            DefaultContainerName="dbA_EmployeesEntities" EnableDelete="false" EnableInsert="False"
            EnableUpdate="False" EntitySetName="ActivePhoneLists" EnableFlattening="False"
            OrderBy="it.LastName, it.FirstName" AutoGenerateWhereClause="False" />
        <br />
        <telerik:RadGrid ID="rgEmployees" Skin="WebBlue" ShowGroupPanel="True" runat="server"
            DataSourceID="edsEmployees" AllowAutomaticDeletes="False" AllowAutomaticInserts="false"
            AllowAutomaticUpdates="false" AllowSorting="True" AllowFilteringByColumn="true"
            AutoGenerateColumns="False" GridLines="None" PagerStyle-Position="Top" AllowPaging="true"
            ClientSettings-Scrolling-AllowScroll="false" ShowStatusBar="true">
            <ExportSettings HideStructureColumns="true" ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true">
            </ExportSettings>
            <MasterTableView DataKeyNames="EmployeeNumber" GroupLoadMode="Client" CommandItemDisplay="Top">
                <CommandItemSettings ShowExportToWordButton="true" ShowExportToExcelButton="true"
                    ShowExportToCsvButton="true" ShowExportToPdfButton="true" ShowAddNewRecordButton="false" />
                <HeaderStyle HorizontalAlign="Left" />
                <Columns>
                    <telerik:GridBoundColumn ReadOnly="true" DataField="EmployeeNumber" UniqueName="EmployeeNumber"
                        HeaderText="Employee Num" Visible="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="LastName" HeaderText="Last Name" ItemStyle-Width="80px"
                        HeaderStyle-Width="80px" FilterControlWidth="50px">
                        <HeaderStyle Width="80px" />
                        <ItemStyle Width="80px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="FirstName" HeaderText="First Name" ItemStyle-Width="80px"
                        HeaderStyle-Width="80px" FilterControlWidth="50px">
                        <HeaderStyle Width="80px" />
                        <ItemStyle Width="80px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Phone" HeaderText="Phone" ItemStyle-Width="90px"
                        HeaderStyle-Width="90px" FilterControlWidth="50px">
                        <HeaderStyle Width="90px" />
                        <ItemStyle Width="90px" />
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
    </div>
    </form>
</body>
</html>


When I take out:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <ClientEvents OnRequestStart="onRequestStart" />
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rgEmployees">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgEmployees" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

I can then export OK. When that's in, the entire radgrid is displayed on my screen.
I don't know of any other code that might help in a zip file.  ??

Thanks again,
Dan

0
Daniel
Telerik team
answered on 27 Jan 2011, 05:24 PM
Hello Dan,

I tried to reproduce the issue but unfortunately to no avail. Please download the attached project (based on your code) and let me know if I'm missing something.

Best regards,
Daniel
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Dan
Top achievements
Rank 1
answered on 31 Jan 2011, 07:16 PM
Daniel,

I don't remember changing anything, but it seems to be working now. I did reboot over the weekend.

I'm not sure what happened, but thanks for your help.

Dan
0
Dan
Top achievements
Rank 1
answered on 31 Jan 2011, 10:32 PM
Daniel,

OK, now I'm getting different errors. I don't think they're related, so let's call this one closed.

Dan
0
Daniel
Telerik team
answered on 02 Feb 2011, 11:02 PM
Hello Dan,

Do not hesitate to ask any export-related questions in this thread. If your question is not related to RadGrid export it would be better to post it in a separate thread.

Kind regards,
Daniel
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Dan
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Dan
Top achievements
Rank 1
Share this question
or