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

Rebind radgrid after export to excel

10 Answers 281 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Manaswinee
Top achievements
Rank 1
Manaswinee asked on 18 Nov 2010, 10:35 AM
Hello,
       I am using radgrid and it is ajaxified by RadAjaxManager.I am using the exporttoexcel command item for exporting selected records from grid.After exporting the selected records I want to delete them from the grid.They are getting deleted from the DB but the grid is not getting refreshed.The grid.Rebind() is not working.Please guide me regarding this.

Thanks & Regards,
Manaswinee

10 Answers, 1 is accepted

Sort by
0
Manaswinee
Top achievements
Rank 1
answered on 18 Nov 2010, 10:47 AM

 

protected void RGridImportedData_ItemCommand(object source, GridCommandEventArgs e)

 

{

 

if (e.CommandName == Telerik.Web.UI.RadGrid.ExportToExcelCommandName)

 

{

 

if (RGridImportedData.SelectedItems.Count != 0)

 

{

 

foreach (GridDataItem item in RGridImportedData.MasterTableView.Items)

 

{

 

if (!item.Selected)

 

{

item.Visible =

false;

 

}

 

else

 

{

 

String id = item.GetDataKeyValue("OrderId").ToString();

 

 

if (id != null)

 

{

 

OrderController.DeleteIPurchaseRecord(id);

 

}

}

}

 

RGridImportedData.ExportSettings.ExportOnlyData =

true;

 

RGridImportedData.ExportSettings.OpenInNewWindow =

true;

 

RGridImportedData.Columns.FindByUniqueName(

"EditColumn").Display = false;

 

RGridImportedData.Columns.FindByUniqueName(

"DeleteColumn").Display = false;

 

RGridImportedData.Columns.FindByUniqueName(

"IsValid").Visible = false;

 

RGridImportedData.Columns.FindByUniqueName(

"Selected").Visible = false;

 

RGridImportedData.Columns.FindByUniqueName(

"LeadTime").Visible = false;

 

}

 

else

 

{

ShowAlertBox(

"Select records to be exported.");

 

e.Canceled =

true;

 

}

 

}

 

 

//RGridImportedData.EnableViewState = false;

 

 

////perform some actions here

 

 

//RGridImportedData.DataSource = null;

 

 

////call the Rebind() method after nullifying the data source

 

 

//RGridImportedData.Rebind();

 

 

//RGridImportedData.MasterTableView.ClearSelectedItems();

 

}


Hello, above is the code I am using for exporting selected records from radgrid.Kindly suggest if I am doing anything wrong.Any help is appreciated....

Thanks,
Manaswinee

-1
Daniel
Telerik team
answered on 18 Nov 2010, 12:07 PM
Hello Manaswinee,

The only way to refresh RadGrid after the export has been started is to save the output to a file and then cancel the export by refreshing the whole page (Response.Redirect).
The following blog post will be a good starting point for you:
How To: Export grid to PDF file and show the result using the window

Regards,
Daniel
the Telerik team
Browse the vast support resources we have to jumpstart 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
Manaswinee
Top achievements
Rank 1
answered on 18 Nov 2010, 12:29 PM
Hello Daniel,
                   Thanks for your response. But the link given by you is not opening.Could you please elaborate a little as I am new to Telerik as well as  to asp.net.Where should I do the changes,in client-side or in the same ItemCommand event of radgrid.


Best Regards,
Manaswinee
0
Manaswinee
Top achievements
Rank 1
answered on 18 Nov 2010, 12:46 PM
Hello Daniel,
               I am able to open the link provided by you.Here the 'path' is a constant string or something else.How could I get the path of the file.In my case the path could be anything as the user will select the location to save the file.

Best Regards,
Manaswinee
0
Daniel
Telerik team
answered on 23 Nov 2010, 10:25 PM
Hello Manaswinee,

I attached a simple demo that uses the same approach as in the blog post. Your users will be able to click on the Download button and then eventually select the desired destination folder.

Best regards,
Daniel
the Telerik team
Browse the vast support resources we have to jumpstart 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
Prashant
Top achievements
Rank 1
answered on 25 Jan 2013, 10:27 AM
Can you give me the solution in which I am able to refresh my Page after export to excel has completed?

I need it ASAP
0
Prashant
Top achievements
Rank 1
answered on 25 Jan 2013, 12:15 PM

Here are the details of my problem

I am using RadAjaxManager on Master page and RadAjaxPanel on my child page. My RadGrid lies in the RadAjaxPanel of my child page.
My RadGrid has the button for "Export to Excel".

When user clicks on the Export to Excel button I have to rebind the same grid with other database and then call the ExportToExcel() method. I have disabled the Ajax as below on click of Export to Excel button click.

function onRequestStart(sender, args) {

if (args.get_eventTarget().indexOf("ExportToExcelButton") >= 0 || 

 

 

 

{

 

 

args.set_enableAjax(

 

false);

}

 

}

Now when user clicks on ExportToExcel button my file gets downloaded on the client end but the grid gets freezed under "loading.. " icon. I have to manually refresh the page to get to my page.

Please send me an example where we bind the grid to other datasource before exporting and after exporting, I can refresh my page.

 

 

0
Daniel
Telerik team
answered on 30 Jan 2013, 09:49 AM
Hello Prashant,

The problem is most probably caused by the fact that you have double ajaxification which is something I would strongly recommend that you avoid in all cases. The best approach in this scenario would be to use RadAjaxManager and RadAjaxManagerProxy instead of mixing RadAjaxManager and RadAjaxPanel controls.

Kind regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Prashant
Top achievements
Rank 1
answered on 30 Jan 2013, 01:26 PM
Hi Daniel,

Thanks for the reply. One more question.

I have HTML tags in my cell of RadGrid along with other data in my RadGrid

For eg. My one of the cell in radgrid contains this value "<html><tr><td>1 row</td></tr>\r\n<tr><td>1 row</td></tr> \r\n</html>".

Now when I call RadGrid.ExportToExcel() method. This data is not getting exported to Excel. All the rows above this cell are getting exported but this row and the rows following this row is not getting exported.

Please help !!!
0
Daniel
Telerik team
answered on 04 Feb 2013, 09:20 AM
Hello Prashant,

RadGrid will not be able to export invalid HTML.

Regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Manaswinee
Top achievements
Rank 1
Answers by
Manaswinee
Top achievements
Rank 1
Daniel
Telerik team
Prashant
Top achievements
Rank 1
Share this question
or