Export indentation as per tree report (#2882)

* Export indentation as per tree report

* Export indentation as per tree report fixed tabs and hardcoded
This commit is contained in:
RicardoJohann 2017-04-06 08:55:46 -03:00 committed by Rushabh Mehta
parent 1d24ea78bd
commit e395de340e

View file

@ -77,6 +77,14 @@ frappe.slickgrid_tools = {
get_filtered_items: function(dataView) {
var data = [];
for (var i=0, len=dataView.getLength(); i<len; i++) {
// remove single quotes at start and end of total labels when print/pdf
var obj = dataView.getItem(i);
for (var item in obj) {
if(obj.hasOwnProperty(item) && typeof(obj[item]) == "string"
&& obj[item].charAt(0) == "'" && obj[item].charAt(obj[item].length -1) == "'") {
dataView.getItem(i)[item] = obj[item].substr(1, obj[item].length-2);
}
}
data.push(dataView.getItem(i));
}
return data;
@ -94,6 +102,16 @@ frappe.slickgrid_tools = {
if(val===null || val===undefined) {
val = "";
}
if(typeof(val) == "string") {
// export to csv and get first or second column of the grid indented if it is. e.g: account_name
if((i<3) && d['indent'] > 0 && (isNaN((new Date(val)).valueOf()))) {
val = " ".repeat(d['indent'] * 8) + val;
}
// remove single quotes at start and end of total labels when export to csv
if(val.charAt(0) == "'" && val.charAt(val.length -1) == "'") {
val = val.substr(1, val.length-2);
}
}
row.push(val);
});