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

Help,why IgnorePaging property doesn't work?

1 Answer 70 Views
Grid
This is a migrated thread and some comments may be shown as answers.
liu qingshui
Top achievements
Rank 1
liu qingshui asked on 04 May 2010, 11:27 AM
When I want to export the data to excel,and I want to export all the data and I set the IgnorePaging Property to true,
but it doesn't work. I can only export the current page's data.How I can export all the pages's data ?

<asp:Button ID="Button1" runat="server" CssClass="button-ts" OnClick="Export" Text="To Excel" />

<
telerik:RadGrid ID="rgridview" runat="server" OnPageIndexChanged="rgridview_PageIndexChanged" 
                                                        OnPageSizeChanged="rgridview_PageSizeChanged" OnSortCommand="rgridview_SortCommand" 
                                                        OnItemDataBound="rgridview_ItemDataBound" Skin="Vista" AlternatingItemStyle-BackColor="#efefef"
                                                        <HeaderStyle BackColor="#efefef" /> 
                                                        <PagerStyle Mode="NumericPages" /> 
                                                        <MasterTableView AutoGenerateColumns="False" DataKeyNames="InvitedPeapleName" AllowPaging="True" 
                                                            EnableViewState="true" AllowSorting="True" PageSize="20" TableLayout="Fixed" 
                                                            Width="950px" ForeColor="Black"
                                                            <NoRecordsTemplate> 
                                                                "没有符合条件的数据! 
                                                            </NoRecordsTemplate> 
                                                            <Columns> 
                                                                <telerik:GridBoundColumn DataField="InvitedPeapleName" HeaderText="被邀请人" SortExpression="InvitedPeapleName" 
                                                                    UniqueName="InvitedPeapleName"
                                                                    <HeaderStyle Wrap="False" Width="48px" /> 
                                                                    <ItemStyle Wrap="False" /> 
                                                                </telerik:GridBoundColumn> 
                                                                <telerik:GridBoundColumn DataField="Department" HeaderText="部门" SortExpression="Department" 
                                                                    UniqueName="Department"
                                                                    <HeaderStyle Wrap="False" Width="80px" /> 
                                                                    <ItemStyle Wrap="False" /> 
                                                                </telerik:GridBoundColumn> 
                                                                <telerik:GridBoundColumn DataField="ActivityName" HeaderText="活动名称" SortExpression="ActivityName" 
                                                                    AllowSorting="false" UniqueName="ActivityName"
                                                                    <HeaderStyle Wrap="False" Width="60px" /> 
                                                                    <ItemStyle Wrap="False" /> 
                                                                </telerik:GridBoundColumn> 
                                                                <telerik:GridBoundColumn DataField="ActivityDate" DataType="System.DateTime" HeaderText="活动时间" 
                                                                    SortExpression="ActivityDate" UniqueName="ActivityDate" DataFormatString="{0:yyyy-MM-dd HH:mm}"
                                                                    <HeaderStyle Width="80px" /> 
                                                                </telerik:GridBoundColumn> 
                                                                <telerik:GridBoundColumn DataField="ActivtiyPlace" HeaderText="活动地点" SortExpression="ActivtiyPlace" 
                                                                    AllowSorting="false" UniqueName="ActivtiyPlace"
                                                                    <HeaderStyle Wrap="False" Width="60px" /> 
                                                                    <ItemStyle Wrap="False" /> 
                                                                </telerik:GridBoundColumn> 
                                                                <telerik:GridBoundColumn DataField="ActivityContent" HeaderText="活动内容" SortExpression="ActivityContent" 
                                                                    AllowSorting="false" UniqueName="ActivityContent"
                                                                    <HeaderStyle Wrap="False" Width="60px" /> 
                                                                    <ItemStyle Wrap="False" /> 
                                                                </telerik:GridBoundColumn> 
                                                                <telerik:GridBoundColumn DataField="ActivityPartner" HeaderText="对方单位" SortExpression="ActivityPartner" 
                                                                    UniqueName="ActivityPartner"
                                                                    <HeaderStyle Wrap="False" Width="50px" /> 
                                                                    <ItemStyle Wrap="False" /> 
                                                                </telerik:GridBoundColumn> 
                                                                <telerik:GridBoundColumn DataField="Reasons" HeaderText="说明" SortExpression="Reasons" 
                                                                    AllowSorting="false" UniqueName="Reasons"
                                                                    <HeaderStyle Wrap="False" Width="80px" /> 
                                                                    <ItemStyle Wrap="False" /> 
                                                                </telerik:GridBoundColumn> 
                                                                <telerik:GridBoundColumn DataField="JoinOrNo" HeaderText="是否参加" SortExpression="JoinOrNo" 
                                                                    UniqueName="JoinOrNo"
                                                                    <HeaderStyle Wrap="False" Width="40px" /> 
                                                                    <ItemStyle Wrap="False" /> 
                                                                </telerik:GridBoundColumn> 
                                                            </Columns> 
                                                            <PagerTemplate> 
                                                                <div style="float: left;"
                                                                    共<%# DataBinder.Eval(Container, "Paging.DataSourceCount")%>条 &nbsp&nbsp每页<%# DataBinder.Eval(Container,"Paging.PageSize") %>条 
                                                                    &nbsp&nbsp当前第<%# (int)DataBinder.Eval(Container, "Paging.CurrentPageIndex") + 1 %> 
                                                                    页/共<%# DataBinder.Eval(Container, "Paging.PageCount")%>页 
                                                                    <asp:Button ID="Button1" runat="server" OnClientClick="changePage('first'); return false;" 
                                                                        CommandName="Page" CommandArgument="First" Text="首页" CssClass="PagerButton FirstPage" /> 
                                                                    <asp:Button ID="Button2" runat="server" OnClientClick="changePage('prev'); return false;" 
                                                                        CommandName="Page" CommandArgument="Prev" Text="上一页" CssClass="PagerButton PrevPage" /> 
                                                                    <asp:Button ID="Button3" runat="server" OnClientClick="changePage('next'); return false;" 
                                                                        CommandName="Page" CommandArgument="Next" Text="下一页" CssClass="PagerButton NextPage" /> 
                                                                    <asp:Button ID="Button4" runat="server" OnClientClick="changePage('last'); return false;" 
                                                                        CommandName="Page" CommandArgument="Last" Text="尾页" CssClass="PagerButton LastPage" /> 
                                                                    转到第 
                                                                    <telerik:RadNumericTextBox ID="RadNumericTextBox1" Width="25px" Value='<%# (int)DataBinder.Eval(Container, "Paging.CurrentPageIndex") + 1 %>' 
                                                                        runat="server"
                                                                        <ClientEvents OnValueChanged="RadNumericTextBox1_ValueChanged" /> 
                                                                        <NumberFormat DecimalDigits="0" /> 
                                                                    </telerik:RadNumericTextBox> 
                                                                    页 
                                                                </div> 
                                                            </PagerTemplate> 
                                                        </MasterTableView> 
                                                        <ClientSettings> 
                                                            <Selecting AllowRowSelect="True" /> 
                                                        </ClientSettings> 
                                                    </telerik:RadGrid>

 protected void Export(object sender, EventArgs e) 
    { 
         
        rgridview.ExportSettings.ExportOnlyData = true
        rgridview.ExportSettings.IgnorePaging =true
        rgridview.ExportSettings.OpenInNewWindow = false
        rgridview.MasterTableView.ExportToExcel(); 
    } 



1 Answer, 1 is accepted

Sort by
0
liu qingshui
Top achievements
Rank 1
answered on 05 May 2010, 09:41 AM
I try several methods, all didn't work.
Finally I found you can solve this problem by rebinding the data  in the event of OnClick.
The following code is my successful code:

protected void Export(object sender, EventArgs e) 
    { 
        Binding();                               //This is the method for rebinding.
        rgridview.ExportSettings.ExportOnlyData = true
        rgridview.ExportSettings.IgnorePaging = true
        rgridview.MasterTableView.ExportToExcel(); 
    } 

Tags
Grid
Asked by
liu qingshui
Top achievements
Rank 1
Answers by
liu qingshui
Top achievements
Rank 1
Share this question
or