Hi,
i m using grid client side binding with page methods. i want to export grid data to excel but i think there is a bug or something is wrong
in my code.
sample code;
i m using grid client side binding with page methods. i want to export grid data to excel but i think there is a bug or something is wrong
in my code.
sample code;
function
exportToExcel(fileName) {
var objGrid = $find("<%= grid.ClientID %>").get_masterTableView();
objGrid.exportToExcel(fileName);
}
function
requestStart(sender, args){
if (args.get_eventArgument().indexOf("Export") != -1) {
args.set_enableAjax(
false);
}
}
also i tried this to use ajaxmanager but OnRequestStart event does not fire, because my page does not post back..
when i try to use grid like your samples; bind grid with sqldatasource excelExport works, but when i try to binding on client side
excelExport does not work..
How can i solve this problem?
thanks..
7 Answers, 1 is accepted
0
Hello Ihsan,
Note that RadGrid generates the output file on the server and therefore the client-side databinding won't work in this case. A possible approach is to assign a temporary data-source on the server before export.
Let me know if you need more information.
Best regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Note that RadGrid generates the output file on the server and therefore the client-side databinding won't work in this case. A possible approach is to assign a temporary data-source on the server before export.
Let me know if you need more information.
Best regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
ihsan
Top achievements
Rank 1
answered on 11 Jun 2009, 12:26 PM
thanks for your quick reply..
if you can send some sample code it will be very helpfull..
I mean can we do this with ajax pageMethods?
there ara lots of ways to export some data to excel but i m looking for best and lowest development time
to do this.. Please share your ideas with me..
thanks in advance..
if you can send some sample code it will be very helpfull..
I mean can we do this with ajax pageMethods?
there ara lots of ways to export some data to excel but i m looking for best and lowest development time
to do this.. Please share your ideas with me..
thanks in advance..
0
ihsan
Top achievements
Rank 1
answered on 13 Jun 2009, 04:40 PM
hi again,
i tried a lot of ways to export grid to excel but anyone did not work!
your demo works but in your demo you are using sqldatasource but i cant use it..
also your grid works with pagemethods but why excel export doesn't work with this scenario?
i m using business objects to bind grid's data. i tried to export grid on code behind with post back (button click event)
and after page postback page ask me open or save window for excel.. and then i click open and page starts to download file
from server.. after 3-5 seconds a silly javascript error like this; No such interface supported ...
please help..
i tried a lot of ways to export grid to excel but anyone did not work!
your demo works but in your demo you are using sqldatasource but i cant use it..
also your grid works with pagemethods but why excel export doesn't work with this scenario?
i m using business objects to bind grid's data. i tried to export grid on code behind with post back (button click event)
and after page postback page ask me open or save window for excel.. and then i click open and page starts to download file
from server.. after 3-5 seconds a silly javascript error like this; No such interface supported ...
| protected void btnExportToExcel_Click(object sender, EventArgs e) | |
| { | |
| try | |
| { | |
| IList<Erciyes.Business.Model.Customers> list = Erciyes.Business.Customers.GetCustomersByFilter(0, 10, "", ""); | |
| grid.ExportSettings.IgnorePaging = true; | |
| grid.ExportSettings.ExportOnlyData = true; | |
| //grid.ExportSettings.OpenInNewWindow = true; | |
| //grid.DataSource = list; | |
| //grid.DataBind(); | |
| grid.MasterTableView.ExportToExcel(); | |
| } | |
| catch (Exception ex) | |
| { | |
| throw ex; | |
| } | |
| } |
please help..
0
Hello Ihsan,
I found some interesting links about this error:
Internet Explorer Cannot Download - No such interface supported
JavaScript Error: No Such Interface Supported Solved
You cannot open a new Internet Explorer window or nothing occurs after you click a link
Also I recommend you use the following approach to bind RadGrid on button click:
Best regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
I found some interesting links about this error:
Internet Explorer Cannot Download - No such interface supported
JavaScript Error: No Such Interface Supported Solved
You cannot open a new Internet Explorer window or nothing occurs after you click a link
Also I recommend you use the following approach to bind RadGrid on button click:
| protected void Button1_Click(object sender, EventArgs e) |
| { |
| RadGrid1.DataSource = GetMyData(); |
| RadGrid1.ExportSettings.ExportOnlyData = true; |
| RadGrid1.ExportSettings.IgnorePaging = true; |
| RadGrid1.Rebind(); |
| RadGrid1.MasterTableView.ExportToExcel(); |
| } |
Best regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Radovan Radic
Top achievements
Rank 1
answered on 06 Oct 2009, 11:00 AM
Daniel,
This last example helped me to export client databound grid.
But, I don't know how I can get actual startRow and maximumRows so I can export only that one page I am seeing? I have grid with ~70 records and I am doing client side paging and showing 10 records at the time.
Thanks,
Radovan
This last example helped me to export client databound grid.
But, I don't know how I can get actual startRow and maximumRows so I can export only that one page I am seeing? I have grid with ~70 records and I am doing client side paging and showing 10 records at the time.
Thanks,
Radovan
0
Hello Radovan,
You can get the needed data via the client-side API and then pass it using hidden field.
Best regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
You can get the needed data via the client-side API and then pass it using hidden field.
...var masterTable = $find("RadGrid1").get_masterTableView();var currentPage = masterTable.get_currentPageIndex();var pageSize = masterTable.get_pageSize();hiddenField.value = currentPage + "|" + pageSize;....Best regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Radovan Radic
Top achievements
Rank 1
answered on 13 Oct 2009, 08:52 AM
Daniel,
Thanks for this tip, it really helped.
Radovan
Thanks for this tip, it really helped.
Radovan