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

RadGrid. Client Side Export.

4 Answers 444 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Den
Top achievements
Rank 1
Den asked on 16 May 2012, 01:40 PM
Hi!
I have a RadGrid. The grid gets data from a webservice. I want to export data to Excel. I am trying to use exportToExcel method, but it doesn't work.
How can I export data to Excel?
Thanks for your help!

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 17 May 2012, 12:11 PM
Hi,

Please make sure that you consume the webservice on the server and not on the client. When bound on client RadGrid does not persist data that will be used when export on server.

Thanks,
Shinu
0
Den
Top achievements
Rank 1
answered on 21 May 2012, 07:48 AM
Hi.

The grid uses client binding. Is there any workaround to do export?

Thanks.

0
Shinu
Top achievements
Rank 2
answered on 21 May 2012, 08:28 AM
Hi Den,

You have to bind RadGrid on the server only when exporting. Try this approach:

ASPX:
<asp:Button ID="Button1" runat="server" Text="Export" OnClick="Button1_Click" />
<telerik:RadGrid  ID="RadGrid2" AllowSorting="true"  AllowPaging="true"
     ...
     <ClientSettings>
         <DataBinding Location="~/MyWebService.asmx"  EnableCaching="true"
             SelectMethod="GetData"  />
     </ClientSettings>
</telerik:RadGrid>

C#:
protected void Button1_Click(object sender, EventArgs e)
{
    RadGrid1.DataSource = MyWebService.GetData();
    RadGrid1.Rebind();
    RadGrid1.MasterTableView.ExportToCSV();
}

Thanks,
Shinu.
0
Den
Top achievements
Rank 1
answered on 21 May 2012, 08:47 AM
Thanks for your help. It works.
Tags
Grid
Asked by
Den
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Den
Top achievements
Rank 1
Share this question
or