free-jqgrid / jqGrid

jQuery grid plugin
https://github.com/free-jqgrid/jqGrid
Other
478 stars 196 forks source link

csv download plugin #480

Open veto64 opened 4 years ago

veto64 commented 4 years ago

hi, i would like to start contribute to this great project and i added a small plugin to download the grid as a CSV file. please guide me about any code style standards and your requirements

thanks, veto

veto64 commented 4 years ago

example usage : .jqGrid("navButtonAdd", "#grid_toppager", { caption: "Download CSV", id:"download", buttonicon: "fa-file-excel-o", onClickButton: function(err,res){ jQuery(this).jqGrid("jqgrid_download",'csv'); } });

Nimesin-Boxmark commented 4 years ago

Can you change code so it will have few new parameters, with default values:

Line 50: jqgrid_download: function (format , separator = ',', endline = '\n' )

Line 76: let csv = "data:text/csv;charset=utf-8," + rows.map(e => e.join(separator)).join(endline);

So there can be different separators and line ends used (we use here ';' as separator, and windows line end is '\r\n')

And, can you organize line 52 as switch/case, so it can be easily extended for more formats?

veto64 commented 4 years ago

apologize for late reply,

i just changed it: https://github.com/veto64/jqGrid/blob/master/plugins/jqgrid_download.js