Fixed #2395 - New `exportFooter` property for Exportable DataTable
parent
ef103e0e34
commit
1a43e8a6f2
|
@ -239,6 +239,12 @@ const ColumnProps = [
|
|||
default: "null",
|
||||
description: "Custom export header of the column to be exported as CSV."
|
||||
},
|
||||
{
|
||||
name: "exportFooter",
|
||||
type: "string",
|
||||
default: "null",
|
||||
description: "Custom export footer of the column to be exported as CSV."
|
||||
},
|
||||
{
|
||||
name: "hidden",
|
||||
type: "boolean",
|
||||
|
|
|
@ -233,6 +233,10 @@ export interface ColumnProps {
|
|||
* Custom export header of the column to be exported as CSV.
|
||||
*/
|
||||
exportHeader?: string | undefined;
|
||||
/**
|
||||
* Custom export footer of the column to be exported as CSV.
|
||||
*/
|
||||
exportFooter?: string | undefined;
|
||||
/**
|
||||
* Defines the filtering algorithm to use when searching the options.
|
||||
*/
|
||||
|
|
|
@ -166,6 +166,10 @@ export default {
|
|||
type: String,
|
||||
default: null
|
||||
},
|
||||
exportFooter: {
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
filterMatchMode: {
|
||||
type: String,
|
||||
default: null
|
||||
|
|
|
@ -1072,6 +1072,24 @@ export default {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
//footers
|
||||
let footerInitiated = false;
|
||||
for (let i = 0; i < this.columns.length; i++) {
|
||||
let column = this.columns[i];
|
||||
|
||||
if (i === 0) csv += '\n';
|
||||
|
||||
if (this.columnProp(column, 'exportable') !== false && this.columnProp(column, 'field')) {
|
||||
if (footerInitiated)
|
||||
csv += this.csvSeparator;
|
||||
else
|
||||
footerInitiated = true;
|
||||
|
||||
csv += '"' + (this.columnProp(column, 'exportFooter') || this.columnProp(column, 'footer') || this.columnProp(column, 'field')) + '"';
|
||||
}
|
||||
}
|
||||
|
||||
DomHandler.exportCSV(csv, this.exportFilename);
|
||||
},
|
||||
resetPage() {
|
||||
|
|
|
@ -381,6 +381,12 @@ export default {
|
|||
<td>null</td>
|
||||
<td>Custom export header of the column to be exported as CSV.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>exportFooter</td>
|
||||
<td>string</td>
|
||||
<td>null</td>
|
||||
<td>Custom export footer of the column to be exported as CSV.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>filterMatchMode</td>
|
||||
<td>string</td>
|
||||
|
|
Loading…
Reference in New Issue