Fixed #2395 - New `exportFooter` property for Exportable DataTable

pull/2835/head
Tuğçe Küçükoğlu 2022-08-10 16:22:48 +03:00
parent ef103e0e34
commit 1a43e8a6f2
5 changed files with 38 additions and 0 deletions

View File

@ -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",

View File

@ -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.
*/

View File

@ -166,6 +166,10 @@ export default {
type: String,
default: null
},
exportFooter: {
type: String,
default: null
},
filterMatchMode: {
type: String,
default: null

View File

@ -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() {

View File

@ -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>