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

Export Grouped Data From Paged Grid

4 Answers 84 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Christine
Top achievements
Rank 1
Christine asked on 24 Sep 2012, 01:33 PM
When exporting grouped data, the exports do not contain previous page data when the page selection is anything other than page 1.  Example: If page 2 is selected, the export data begins on page 2 and doesn't contain the data from page 1.  This doesn't happen when the data isn't grouped.  Is this by design?

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Sep 2012, 04:19 AM
Hi,

Try setting the following.
aspx:
<ExportSettings IgnorePaging="true" Excel-Format="Html"></ExportSettings>

Thanks,
Shinu.
0
Christine
Top achievements
Rank 1
answered on 26 Sep 2012, 01:07 PM
Thanks, however it didn't correct the behavior.  I'll try to put together sample code reproducing this.  I should note this happens with Word, CSV and Excel exports.  Simply group the results by one of the columns, select a page other than page one, and hit one of the export buttons.

Here is a sample code set:

<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('ExportToCsvButton') >= 0) {
            args.set_enableAjax(false);
        }
    }
 
</script>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <ClientEvents OnRequestStart="onRequestStart" />
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadGrid1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadGrid ID="RadGrid1" AllowSorting="True" OnNeedDataSource="GridNeedDataSource" ShowGroupPanel="True"
    AllowPaging="True" runat="server" GridLines="None" Width="95%" CellSpacing="0">
    <GroupingSettings CaseSensitive="false" ShowUnGroupButton="true" />
    <ClientSettings AllowColumnsReorder="true" AllowDragToGroup="true" AllowGroupExpandCollapse="True">
        <Resizing AllowColumnResize="true" AllowResizeToFit="false" EnableRealTimeResize="false" ResizeGridOnColumnResize="false" />
        <Animation AllowColumnReorderAnimation="True" AllowColumnRevertAnimation="True" />
        <Scrolling AllowScroll="true" UseStaticHeaders="true" />
    </ClientSettings>
    <ExportSettings HideStructureColumns="True" IgnorePaging="True" ExportOnlyData="True" OpenInNewWindow="True" Excel-Format="Html" />
    <MasterTableView Width="100%" CommandItemDisplay="Top">
        <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>
        <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
        <EditFormSettings>
            <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
        </EditFormSettings>
        <PagerStyle Mode="NextPrevNumericAndAdvanced" />
        <CommandItemSettings ShowExportToWordButton="true" ShowExportToExcelButton="true" ShowExportToCsvButton="true" />
    </MasterTableView>
    <FilterMenu EnableImageSprites="False"></FilterMenu>
</telerik:RadGrid>
</form>


protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        CreateDataSource();
    }
}
 
protected void GridNeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
    RadGrid1.DataSource = (DataTable)Session["resultsTable"];
}
 
private void CreateDataSource()
{
    DataSet resultsDS = new DataSet();
    DataTable resultsTable = resultsDS.Tables.Add();
 
    //-- Add columns to the data table
    resultsTable.Columns.Add("Folder", typeof(string));
    resultsTable.Columns.Add("Group", typeof(string));
    resultsTable.Columns.Add("ID", typeof(string));
    resultsTable.Columns.Add("Customer", typeof(string));
    resultsTable.Columns.Add("PurchaseDate", typeof(string));
 
    //-- Add rows to the data table
    resultsTable.Rows.Add("Folder Name", "28281000", "2828100045800002", "Customer One<br>123 Main St<br>City, ST  12345", "01/01/2012");
    resultsTable.Rows.Add("Folder Name", "28281000", "2828100045800002", "FirstName LastName<br>Address<br>CityStateZIP", "07/23/2008");
    resultsTable.Rows.Add("Folder Name", "28281000", "2828100045800003", "Essie Vaill<br>14225 Hancock Dr<br>Anchorage, AK  99515", "07/23/2008");
    resultsTable.Rows.Add("Folder Name", "28281000", "2828100045800004", "Cruz Roudabush<br>2202 S Central Ave<br>Phoenix, AZ  85004", "07/23/2008");
    resultsTable.Rows.Add("Folder Name", "28281000", "2828100045800005", "Billie Tinnes<br>28 W 27th St<br>New York, NY  10001", "07/23/2008");
    resultsTable.Rows.Add("Folder Name", "28281000", "2828100045800006", "Zackary Mockus<br>286 State St<br>Perth Amboy, NJ  8861", "07/23/2008");
    resultsTable.Rows.Add("Folder Name", "28281000", "2828100045800007", "Rosemarie Fifield<br>3131 N Nimitz Hwy  #-105<br>Honolulu, HI  96819", "07/23/2008");
    resultsTable.Rows.Add("Folder Name", "28281000", "2828100045800008", "Bernard Laboy<br>22661 S Frontage Rd<br>Channahon, IL  60410", "07/23/2008");
    resultsTable.Rows.Add("Folder Name", "28281000", "2828100045800009", "Sue Haakinson<br>9617 N Metro Pky W<br>Phoenix, AZ  85051", "07/23/2008");
    resultsTable.Rows.Add("Folder Name", "28281000", "2828100045800010", "Valerie Pou<br>7475 Hamilton Blvd<br>Trexlertown, PA  18087", "07/23/2008");
    resultsTable.Rows.Add("Folder Name", "28281000", "2828100045800011", "Lashawn Hasty<br>815 S Glendora Ave<br>West Covina, CA  91790", "07/23/2008");
    resultsTable.Rows.Add("Folder Name", "28281000", "2828100045800012", "Marianne Earman<br>6220 S Orange Blossom Trl<br>Orlando, FL  32809", "07/23/2008");
    resultsTable.Rows.Add("Folder Name", "28281000", "2828100045800013", "Justina Dragaj<br>2552 Poplar Ave<br>Memphis, TN  38112", "07/23/2008");
    resultsTable.Rows.Add("Folder Name", "28281000", "2828100045800014", "Mandy Mcdonnell<br>343 Bush St Se<br>Salem, OR  97302", "07/23/2008");
    resultsTable.Rows.Add("Folder Name", "28281000", "2828100045800015", "Conrad Lanfear<br>49 Roche Way<br>Youngstown, OH  44512", "07/23/2008");
    resultsTable.Rows.Add("Folder Name", "28281000", "2828100045800016", "Cyril Behen<br>1650 S Harbor Blvd<br>Anaheim, CA  92802", "07/23/2008");
    resultsTable.Rows.Add("Folder Name", "28281000", "2828100045800017", "Shelley Groden<br>110 Broadway St<br>San Antonio, TX  78205", "07/23/2008");
    resultsTable.Rows.Add("Folder Name", "28281000", "2828100045800018", "Rosalind Krenzke<br>7000 Bass Lake Rd  #-200<br>Minneapolis, MN  55428", "07/23/2008");
    resultsTable.Rows.Add("Folder Name", "28281000", "2828100045800019", "Davis Brevard<br>6715 Tippecanoe Rd<br>Canfield, OH  44406", "07/23/2008");
    resultsTable.Rows.Add("Folder Name", "28281000", "2828100045800020", "Winnie Reich<br>1535 Hawkins Blvd<br>El Paso, TX  79925", "07/23/2008");
    resultsTable.Rows.Add("Folder Name", "28281000", "2828100045800021", "Trudy Worlds<br>24907 Tibbitts Aven  #-b<br>Valencia, CA  91355", "07/23/2008");
    resultsTable.Rows.Add("Folder Name", "28281000", "2828100045800022", "Deshawn Inafuku<br>3508 Leopard St<br>Corpus Christi, TX  78408", "07/23/2008");
 
    Session["resultsTable"] = resultsTable;
}

0
Shinu
Top achievements
Rank 2
answered on 27 Sep 2012, 06:04 AM
Hi,

Try setting the page index to export all pages after grouping.
C#:
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.ExportToExcelCommandName)
    {
      RadGrid1.GroupingEnabled = false;
      RadGrid1.CurrentPageIndex = 0;
      RadGrid1.Rebind();
    }
}

Thanks,
Shinu.
0
Christine
Top achievements
Rank 1
answered on 27 Sep 2012, 02:21 PM
That fixed the issue, however I wanted the data to remain grouped, so I left grouping enabled.  Setting the page index to 0 and the rebind gave me what I was looking for!
Thanks!
Tags
Grid
Asked by
Christine
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Christine
Top achievements
Rank 1
Share this question
or