1
Bug Report / Re: CSV export "Uncaught TypeError: Cannot read property 'hidden' of undefined"
« on: July 13, 2018, 06:27:53 am »
Hi there,
I come across the same issue with the latest version of ParamQuery Pro v5.0.0. It can be easily reproduced when you have column(s) in your grid which have been to set the property "copy" to false.
If you replace the colM object in the demo page with the following, you will see the error:
var colM = [
{ title: "ShipCountry", width: 120, dataIndx: "ShipCountry",
filter: {
type: 'select',
prepend: { '': 'All Countries' },
valueIndx: 'ShipCountry',
labelIndx: 'ShipCountry',
condition: 'equal',
listeners: ['change']
}
},
{ title: "Customer Name", width: 130, dataIndx: "ContactName" },
{ title: "Test2 Customer Name", width: 130, dataIndx: "ContactName", copy: false },
{ title: "Freight", width: 120, format: '$##,###.00',
summary: {
type: "sum"
},
dataType: "float", dataIndx: "Freight"
},
{ title: "Shipping Via", width: 130, dataIndx: "ShipVia" },
//{ title: "Shipped Date", width: 100, dataIndx: "ShippedDate", dataType: "date" },
{ title: "Shipping Address", width: 220, dataIndx: "ShipAddress" },
{ title: "Shipping City", width: 130, dataIndx: "ShipCity" }
];
When I dig into the source code of the library, I figure out that there may be a potential bug in the method getCsvHeader.
getCsvHeader: function(hc, hcLen, CM, separator) {
var self = this,
header = [],
csvRows = [],
column, cell, title;
for (var i = 0; i < hcLen; i++) {
var row = hc,
laidCell = null;
for (var ci = 0, lenj = row.length; ci < lenj; ci++) {
// Bug causing not able to download CSV file
column = CM[ci]; <------ this line causing issue;
if (column.hidden || column.copy === false) {
continue
}
cell = row[ci];
if (i > 0 && cell == hc[i - 1][ci]) {
header.push("")
} else if (laidCell && ci > 0 && cell == laidCell) {
header.push("")
} else {
title = self.getTitle(cell, ci);
title = title ? title.replace(/\"/g, '""') : "";
laidCell = cell;
header.push('"' + title + '"')
}
}
csvRows.push(header.join(separator));
header = []
}
return csvRows
},
I am not sure if this is a bug, if yes, I am looking forward to a fix as we cannot export our data to CSV now.
Thanks!
I come across the same issue with the latest version of ParamQuery Pro v5.0.0. It can be easily reproduced when you have column(s) in your grid which have been to set the property "copy" to false.
If you replace the colM object in the demo page with the following, you will see the error:
var colM = [
{ title: "ShipCountry", width: 120, dataIndx: "ShipCountry",
filter: {
type: 'select',
prepend: { '': 'All Countries' },
valueIndx: 'ShipCountry',
labelIndx: 'ShipCountry',
condition: 'equal',
listeners: ['change']
}
},
{ title: "Customer Name", width: 130, dataIndx: "ContactName" },
{ title: "Test2 Customer Name", width: 130, dataIndx: "ContactName", copy: false },
{ title: "Freight", width: 120, format: '$##,###.00',
summary: {
type: "sum"
},
dataType: "float", dataIndx: "Freight"
},
{ title: "Shipping Via", width: 130, dataIndx: "ShipVia" },
//{ title: "Shipped Date", width: 100, dataIndx: "ShippedDate", dataType: "date" },
{ title: "Shipping Address", width: 220, dataIndx: "ShipAddress" },
{ title: "Shipping City", width: 130, dataIndx: "ShipCity" }
];
When I dig into the source code of the library, I figure out that there may be a potential bug in the method getCsvHeader.
getCsvHeader: function(hc, hcLen, CM, separator) {
var self = this,
header = [],
csvRows = [],
column, cell, title;
for (var i = 0; i < hcLen; i++) {
var row = hc,
laidCell = null;
for (var ci = 0, lenj = row.length; ci < lenj; ci++) {
// Bug causing not able to download CSV file
column = CM[ci]; <------ this line causing issue;
if (column.hidden || column.copy === false) {
continue
}
cell = row[ci];
if (i > 0 && cell == hc[i - 1][ci]) {
header.push("")
} else if (laidCell && ci > 0 && cell == laidCell) {
header.push("")
} else {
title = self.getTitle(cell, ci);
title = title ? title.replace(/\"/g, '""') : "";
laidCell = cell;
header.push('"' + title + '"')
}
}
csvRows.push(header.join(separator));
header = []
}
return csvRows
},
I am not sure if this is a bug, if yes, I am looking forward to a fix as we cannot export our data to CSV now.
Thanks!