Skip to content
Snippets Groups Projects
Commit a22c1c51 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Better Coding for grid.mixin.ExportCSV.

parent a0f9412d
No related branches found
No related tags found
No related merge requests found
......@@ -53,25 +53,22 @@ Ext.define('App.grid.mixin.ExportCSV', {
"use strict";
var me = this,
cells,
columnHeader,
csv = [],
labels = [],
div,
i,
j,
tdEls,
trEl,
labels,
trEls,
row,
total;
// build the row containing the column labels
columnHeader = this.getColumnHeader();
columnHeader = me.getColumnHeader();
if (!columnHeader.hidden) {
for (i = 0; i < columnHeader.labels.length; i += 1) {
labels.push(this.delimit(columnHeader.labels[i]));
}
labels = columnHeader.labels;
Ext.Array.each(labels, function (label, i) {
labels[i] = me.delimit(label);
}, me);
csv.push(labels.join(this.separator));
}
......@@ -83,16 +80,16 @@ Ext.define('App.grid.mixin.ExportCSV', {
trEls = me.getView().getEl().select("table tr");
// process the trEls Ext.dom.CompositeElement
for (i = 0; i < trEls.getCount(); i += 1) {
trEls.each(function (trEl, compositeElement, index) {
trEl = trEls.item(i);
var cells, div, row, tdEls;
// grouping row
if (trEl.hasCls("x-grid-wrap-row")) {
div = trEl.down(".x-grid-group-title");
if (div) {
csv.push(this.delimit(div.dom.textContent));
csv.push(me.delimit(div.dom.textContent));
}
// row with standard data cells. It includes summary row.
......@@ -102,20 +99,21 @@ Ext.define('App.grid.mixin.ExportCSV', {
tdEls = trEl.select("td");
// process the tdEls Ext.dom.CompositeElement
for (j = 0; j < tdEls.getCount(); j += 1) {
cells.push(this.delimit(tdEls.item(j).dom.textContent));
}
tdEls.each(function (tdEl) {
cells.push(me.delimit(tdEl.dom.textContent));
}, me);
row = cells.join(this.separator);
// unfortunately the grand total appear as the first row (Ext JS 4.2)
if (i === 0 && trEl.hasCls("x-grid-row-summary")) {
// unfortunately the grand total is the first row (Ext JS 4.2)
if (index === 0 && trEl.hasCls("x-grid-row-summary")) {
total = row;
} else {
csv.push(row);
}
}
}
}, me);
// push the grand total at the end
if (total) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment