开发者

Exporting data in enhanced Grid to csv or xml format using dojo

开发者 https://www.devze.com 2023-03-25 02:23 出处:网络
In my project we are using dojo framework in UI. We are having a functionality to exporting the data in the enhanced grid into excel/csv files. In t开发者_StackOverflow社区he dojo toolkit, they are bi

In my project we are using dojo framework in UI. We are having a functionality to exporting the data in the enhanced grid into excel/csv files. In t开发者_StackOverflow社区he dojo toolkit, they are binding the id in the textarea but i need those values in the excel/csv file...can any one help in this issue...? if possible pls tell me how to export the enhanced grid data to excel/csv files...


If you are already using the Enhanced Data Grid, you should be able to include the exporter plugin - dojox.grid.enhanced.plugins.exporter.CSVWriter - to get the CSV text.

This will give you access to two main functions exportGrid and exportSelected that will take the contents and export them as CSV text.

Unfortunately that doesn't get them as a separate file (click to download), just the formatted text in a textarea (or whatever).

To get a "click to download CSV function), you could write a servlet/jsp proxy, which would take a POST from your page with the CSV text (from the plugin above) as part of the form and simply copy it back out with the correct headers to make it appear as an attachment.

response.setContentType("text/csv"); response.setHeader("Content-Disposition","attatchment;filename=name.csv")

This would require something server side though.. and at that point, you may want to consider having a servlet simply produce the CSV text directly.

http://dojotoolkit.org/reference-guide/dojox/grid/EnhancedGrid/plugins/Exporter.html

0

精彩评论

暂无评论...
验证码 换一张
取 消