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

ExportToCVS not working

1 Answer 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Russ
Top achievements
Rank 1
Russ asked on 18 Mar 2015, 03:35 PM
Two issues:

1) I am trying to export a radgrid to CSV. The button is configured to call back to C# and I see the code hit MasterTableView.ExportToCSV(), but I step over that line and nothing happens.
2) After hitting the export button and going through the code, the data in the table disappears.

ASP
<telerik:RadGrid ID="rgResources" runat="server" AutoGenerateColumns="false" ShowGroupPanel="false"
    OnPreRender="rgResources_PreRender1" OnColumnCreated="rgResources_ColumnCreated" OnItemCommand="rgResources_ItemCommand"
    GroupingEnabled="false" ShowFooter="true">
    <ClientSettings>
        <Selecting AllowRowSelect="false"></Selecting>
        <Scrolling AllowScroll="true" SaveScrollPosition="true" FrozenColumnsCount="2" UseStaticHeaders="true"
            ScrollHeight="150px"></Scrolling>
    </ClientSettings>
    <MasterTableView DataKeyNames="Resource" CommandItemDisplay="Top" AllowSorting="false"
        AutoGenerateColumns="true" ShowGroupFooter="true">
        <CommandItemSettings ShowExportToCsvButton="true" ShowAddNewRecordButton="false"  ShowRefreshButton="false" />
        <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
        </RowIndicatorColumn>
        <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
        </ExpandCollapseColumn>
    </MasterTableView>
    <ExportSettings IgnorePaging="true">
        <Csv FileExtension="CSV" />
    </ExportSettings>
    <FilterMenu EnableImageSprites="False">
    </FilterMenu>
    <ClientSettings EnableRowHoverStyle="true">
    </ClientSettings>
</telerik:RadGrid>

C#
protected void rgResources_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
    if (e.CommandName == Telerik.Web.UI.RadGrid.ExportToCsvCommandName)
    {
        rgResources.MasterTableView.ExportToCSV();
    }
}

I'm very new to this so I'm sure I'm missing something obvious but could use some help being pointed in the right direction.

Thanks

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 23 Mar 2015, 11:01 AM
Hi Russ,

The data could disappear if you are using Simple Data-Binding, where the data is provided only on the initial page load. If you are going to use complex operations like grouping, sorting, filtering, etc., you need to use the Advanced Data-Binding (through the OnNeedDataSource event). Detailed information this binding is available in the following help article:
Additionally, if your RadGrid is with enabled AJAX, please follow the suggestions from the article below:
Hope this helps.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Russ
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or