Skip to navigation
Free-jqgrid what can download the grid data to csv via javascript
10.07.19
jQuery(function () { "use strict"; jQuery("#grid").jqGrid({ data: {{data|safe}}, colModel: {{model|safe}}, autowith:true, iconSet: 'fontAwesome', searching: {defaultSearch: "bw"}, pagger: true, rowNum:1000, toppager: true }).jqGrid("filterToolbar").jqGrid("inlineNav").jqGrid("gridResize").jqGrid("navButtonAdd", "#grid_toppager", { caption: "Download", id:"download", buttonicon: "fa-file-excel-o", onClickButton: function(err,res){ let data = jQuery(this).jqGrid("getGridParam", "lastSelectedData"); let col = jQuery(this).jqGrid("getGridParam","colModel"); let rows = []; let header = []; for(let c in col) { header.push(col[c]['name']); } rows.push(header) for(let d in data) { let row = []; for(let c in col) { let name = col[c]['name']; row.push(data[d][name]); } rows.push(row); } let csv = "data:text/csv;charset=utf-8," + rows.map(e => e.join(",")).join("\n"); let uri = encodeURI(csv); window.open(uri); } }); });
https://free-jqgrid.github.io/
Reply
Anonymous
Information Epoch 1732638857
Data dominates.
Home
Notebook
Contact us