1
Bug Report / CSV export "Uncaught TypeError: Cannot read property 'hidden' of undefined"
« on: June 27, 2018, 07:54:07 am »
I was trying to track down this error so i beautified pqgrid.min.js and saved it as grid.max.js.
When trying to export to CSV, I get the following output to the chrome console:
Uncaught TypeError: Cannot read property 'hidden' of undefined grid.max.js:10281
at e.cExport.getCsvHeader (grid.max.js:10281)
at e.cExport.getCSVContent (grid.max.js:10290)
at e.cExport.Export (grid.max.js:10150)
at e.(/app/db/anonymous function).(anonymous function).n.exportData (http://localhost/app/db/paramquery/grid.max.js:10105:18)
at e.(/app/db/anonymous function).(anonymous function).listener (http://localhost/app/db/grid.php?table=no_pkg_drawings:151:27)
at HTMLButtonElement.<anonymous> (grid.max.js:6159)
at HTMLButtonElement.dispatch (jquery-1.9.1.min.js:3)
at HTMLButtonElement.v.handle (jquery-1.9.1.min.js:3)
// beautified grid.max.js
},
getCsvHeader: function(t, e, n, r) {
for (var i, o, a, l = this, s = [], d = [], c = 0; e > c; c++) {
for (var u = t[c], h = null, f = 0, p = u.length; p > f; f++) i = n[f], i.hidden || i.copy === !1 || (o = u[f], c > 0 && o == t[c - 1][f] ? s.push("") : h && f > 0 && o == h ? s.push("") : (a = l.getTitle(o, f), a = a ? a.replace(/\"/g, '""') : "", h = o, s.push('"' + a + '"')));
d.push(s.join(r)), s = []
}
return d
},
This seems like a bug. Here is my export code just in case I am doing something wrong.
// jsZip scripts from the SDK
<script src="paramquery/jsZip-2.5.0/jszip.min.js"></script>
<script src="paramquery/jsZip-2.5.0/fileSaver.js"></script>
// toolbar property/object
toolbar: {
items: [
{ type: 'select',
attr: 'id="export_format"',
options: [{
xlsx: 'Export to Excel',
csv: 'Export as CSV',
htm: 'Export as HTML',
json: 'Export as JSON'}]},
{ type: 'button', label: "Export", icon: 'ui-icon-arrowthickstop-1-s',
listener: function () {
$grid.pqGrid("refresh");
var format = $("#export_format").val(),
blob = this.exportData({
format: format,
render: true
});
if(typeof blob === "string"){
blob = new Blob([blob]);
}
saveAs(blob, "'.$this->tableTitle.' export."+ format );
}
},
{ type: 'separator' },
{ type: "<span class=\"feedback\"></span>" }
]
},
When trying to export to CSV, I get the following output to the chrome console:
Uncaught TypeError: Cannot read property 'hidden' of undefined grid.max.js:10281
at e.cExport.getCsvHeader (grid.max.js:10281)
at e.cExport.getCSVContent (grid.max.js:10290)
at e.cExport.Export (grid.max.js:10150)
at e.(/app/db/anonymous function).(anonymous function).n.exportData (http://localhost/app/db/paramquery/grid.max.js:10105:18)
at e.(/app/db/anonymous function).(anonymous function).listener (http://localhost/app/db/grid.php?table=no_pkg_drawings:151:27)
at HTMLButtonElement.<anonymous> (grid.max.js:6159)
at HTMLButtonElement.dispatch (jquery-1.9.1.min.js:3)
at HTMLButtonElement.v.handle (jquery-1.9.1.min.js:3)
// beautified grid.max.js
},
getCsvHeader: function(t, e, n, r) {
for (var i, o, a, l = this, s = [], d = [], c = 0; e > c; c++) {
for (var u = t[c], h = null, f = 0, p = u.length; p > f; f++) i = n[f], i.hidden || i.copy === !1 || (o = u[f], c > 0 && o == t[c - 1][f] ? s.push("") : h && f > 0 && o == h ? s.push("") : (a = l.getTitle(o, f), a = a ? a.replace(/\"/g, '""') : "", h = o, s.push('"' + a + '"')));
d.push(s.join(r)), s = []
}
return d
},
This seems like a bug. Here is my export code just in case I am doing something wrong.
// jsZip scripts from the SDK
<script src="paramquery/jsZip-2.5.0/jszip.min.js"></script>
<script src="paramquery/jsZip-2.5.0/fileSaver.js"></script>
// toolbar property/object
toolbar: {
items: [
{ type: 'select',
attr: 'id="export_format"',
options: [{
xlsx: 'Export to Excel',
csv: 'Export as CSV',
htm: 'Export as HTML',
json: 'Export as JSON'}]},
{ type: 'button', label: "Export", icon: 'ui-icon-arrowthickstop-1-s',
listener: function () {
$grid.pqGrid("refresh");
var format = $("#export_format").val(),
blob = this.exportData({
format: format,
render: true
});
if(typeof blob === "string"){
blob = new Blob([blob]);
}
saveAs(blob, "'.$this->tableTitle.' export."+ format );
}
},
{ type: 'separator' },
{ type: "<span class=\"feedback\"></span>" }
]
},