RadGrid telerik 导出到 Excel 时出现问题
我在 MasterTableView 中添加了以下行:
<CommandItemSettings ShowExportToWordButton="true" ShowExportToExcelButton="true" ShowExportToCsvButton="true" />
但是当我单击该行时,会出现加载 div,然后刷新网格上的数据,并且没有其他反应发生。没有“保存文件”窗口。
我错过了什么吗?
I added folowing line to my MasterTableView:
<CommandItemSettings ShowExportToWordButton="true" ShowExportToExcelButton="true" ShowExportToCsvButton="true" />
But when I click on that, loading div appears and then data on the grid is refreshed and nothing else happens. There is no "save file" window.
Am I missing anything ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在网格之前添加以下代码:
对于后面的代码,添加以下代码:
参考: http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/exporting/defaultcs.aspx
Add the below code before the Grid:
For the code behind add the below one:
reference: http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/exporting/defaultcs.aspx
这是由 AJAX 引起的已知问题(基本上页面需要返回流而不是用于 AJAX 的 XttpReuest),因此需要在此回发上取消 AJAX。
您可以找到更多信息 此处并下载一些示例项目,这些项目展示了导出 radgrid 的各种方式。
附言。
“现成的解决方案”是将其添加到您的 JS 代码中
但我仍然建议您阅读随附的主题 链接
It is known issue caused by the AJAX (basically the page needs to return stream rather than XttpReuest used for AJAX) therefore tha AJAX need to be canceled on this post-back.
You can find more info here and download few sample projects that show various way of exporting radgrid.
PS.
The "ready solution" is to add this to your JS code
But I still recommend you to read the topic in the attached link
我这样做:
我们在网格下有一个按钮:
在 OnClick 处理程序中,您调用 ExportToExcel,然后清除响应标题
在网格上,您有一些 ExportSettings。
我将 ExportSettings.ExportOnlyData = true、ExportSettings.FileName 设置为包含当前数据的唯一名称,并且 IgnorePaging 也设置为 true(所以我只导出所有数据)。
完美运作!
I do it like this:
We have a button under the grid:
And in the OnClick handler you call the ExportToExcel, and then clear the response headers
On the Grid you have some ExportSettings.
I set ExportSettings.ExportOnlyData = true, ExportSettings.FileName to a unique name with current data and IgnorePaging is also true (So i just export all the data).
Works perfectly!
添加导出到excel的按钮;
runat="服务器">
在代码背后:
参考:http://demos。 telerik.com/aspnet-ajax/grid/examples/generalfeatures/exporting/defaultcs.aspx
Add a button for exporting to excel;
runat="server">
On Code behind Side:
Reference: http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/exporting/defaultcs.aspx
将 ClientEvents-OnRequestStart="requestStart" 添加到 RadAjaxPanel
添加脚本
Add the ClientEvents-OnRequestStart="requestStart" to your RadAjaxPanel
Add the script