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

Better Coding for grid.mixin.ExportLatex.

parent a22c1c51
No related branches found
No related tags found
No related merge requests found
...@@ -56,20 +56,10 @@ Ext.define('App.grid.mixin.ExportLatex', { ...@@ -56,20 +56,10 @@ Ext.define('App.grid.mixin.ExportLatex', {
"use strict"; "use strict";
var me = this, var me = this,
cells,
cmd,
columnsAlignment = '', columnsAlignment = '',
columnHeader, columnHeader,
div,
i,
j,
latex = [], latex = [],
nColumns,
tdEl,
tdEls,
trEl,
trEls, trEls,
row,
total; total;
// build the column alignment, e.g. llrrc // build the column alignment, e.g. llrrc
...@@ -78,9 +68,6 @@ Ext.define('App.grid.mixin.ExportLatex', { ...@@ -78,9 +68,6 @@ Ext.define('App.grid.mixin.ExportLatex', {
columnsAlignment += value[0]; columnsAlignment += value[0];
}); });
// alias
nColumns = columnHeader.alignments.length;
// begin table // begin table
latex.push('\\begin{longtable}{' + columnsAlignment + '}'); latex.push('\\begin{longtable}{' + columnsAlignment + '}');
...@@ -99,15 +86,16 @@ Ext.define('App.grid.mixin.ExportLatex', { ...@@ -99,15 +86,16 @@ Ext.define('App.grid.mixin.ExportLatex', {
trEls = me.getView().getEl().select("table tr"); trEls = me.getView().getEl().select("table tr");
// process the trEls Ext.dom.CompositeElement // 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, cmd, div, nColumns, tdEls, row;
// grouping row. It is represent as a latex multicolumn // grouping row. It is represent as a latex multicolumn
if (trEl.hasCls("x-grid-wrap-row")) { if (trEl.hasCls("x-grid-wrap-row")) {
div = trEl.down(".x-grid-group-title"); div = trEl.down(".x-grid-group-title");
if (div) { if (div) {
nColumns = columnHeader.alignments.length;
cmd = '\\multicolumn{' + nColumns + '}{l}{' + me.domToLaTeX(div) + '} \\\\'; cmd = '\\multicolumn{' + nColumns + '}{l}{' + me.domToLaTeX(div) + '} \\\\';
latex.push(cmd); latex.push(cmd);
latex.push('\\hline'); latex.push('\\hline');
...@@ -120,20 +108,20 @@ Ext.define('App.grid.mixin.ExportLatex', { ...@@ -120,20 +108,20 @@ Ext.define('App.grid.mixin.ExportLatex', {
tdEls = trEl.select("td"); tdEls = trEl.select("td");
// process the tdEls Ext.dom.CompositeElement // process the tdEls Ext.dom.CompositeElement
for (j = 0; j < tdEls.getCount(); j += 1) { tdEls.each(function (tdEl) {
cells.push(me.domToLaTeX(tdEls.item(j))); cells.push(me.domToLaTeX(tdEl));
} }, me);
row = cells.join(' & ') + ' \\\\'; row = cells.join(' & ') + ' \\\\';
// unfortunately the grand total appear as the first row (Ext JS 4.2) // unfortunately the grand total is the first row (Ext JS 4.2)
if (i === 0 && trEl.hasCls("x-grid-row-summary")) { if (index === 0 && trEl.hasCls("x-grid-row-summary")) {
total = row; total = row;
} else { } else {
latex.push(row); latex.push(row);
} }
} }
} }, me);
// push the grand total at the end // push the grand total at the end
if (total) { 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