Fixed #2141 - Custom Table CSV Export Headers

pull/2144/head
Tuğçe Küçükoğlu 2022-02-11 12:13:45 +03:00 committed by Tuğçe Küçükoğlu
parent 026021e4cc
commit ddfbd6c095
6 changed files with 25 additions and 5 deletions

View File

@ -233,6 +233,12 @@ const ColumnProps = [
default: "true", default: "true",
description: "Whether the column is included in data export." description: "Whether the column is included in data export."
}, },
{
name: "exportHeader",
type: "string",
default: "null",
description: "Custom export header of the column to be exported as CSV."
},
{ {
name: "hidden", name: "hidden",
type: "boolean", type: "boolean",

View File

@ -229,6 +229,10 @@ export interface ColumnProps {
* Whether the column is included in data export. * Whether the column is included in data export.
*/ */
exportable?: boolean | undefined; exportable?: boolean | undefined;
/**
* Custom export header of the column to be exported as CSV.
*/
exportHeader?: string | undefined;
/** /**
* Defines the filtering algorithm to use when searching the options. * Defines the filtering algorithm to use when searching the options.
*/ */

View File

@ -162,6 +162,10 @@ export default {
type: Boolean, type: Boolean,
default: true default: true
}, },
exportHeader: {
type: String,
default: null
},
filterMatchMode: { filterMatchMode: {
type: String, type: String,
default: null default: null

View File

@ -1033,7 +1033,7 @@ export default {
else else
headerInitiated = true; headerInitiated = true;
csv += '"' + (this.columnProp(column, 'header') || this.columnProp(column, 'field')) + '"'; csv += '"' + (this.columnProp(column, 'exportHeader') || this.columnProp(column, 'header') || this.columnProp(column, 'field')) + '"';
} }
} }

View File

@ -373,6 +373,12 @@ export default {
<td>true</td> <td>true</td>
<td>Whether the column is included in data export.</td> <td>Whether the column is included in data export.</td>
</tr> </tr>
<tr>
<td>exportHeader</td>
<td>string</td>
<td>null</td>
<td>Custom export header of the column to be exported as CSV.</td>
</tr>
<tr> <tr>
<td>filterMatchMode</td> <td>filterMatchMode</td>
<td>string</td> <td>string</td>

View File

@ -16,7 +16,7 @@
<Button icon="pi pi-external-link" label="Export" @click="exportCSV($event)" /> <Button icon="pi pi-external-link" label="Export" @click="exportCSV($event)" />
</div> </div>
</template> </template>
<Column field="code" header="Code"></Column> <Column field="code" header="Code" exportHeader="Product Code"></Column>
<Column field="name" header="Name"></Column> <Column field="name" header="Name"></Column>
<Column field="category" header="Category"></Column> <Column field="category" header="Category"></Column>
<Column field="quantity" header="Quantity"></Column> <Column field="quantity" header="Quantity"></Column>
@ -47,7 +47,7 @@ export default {
<Button icon="pi pi-external-link" label="Export" @click="exportCSV($event)" /> <Button icon="pi pi-external-link" label="Export" @click="exportCSV($event)" />
</div> </div>
</template> </template>
<Column field="code" header="Code"></Column> <Column field="code" header="Code" exportHeader="Product Code"></Column>
<Column field="name" header="Name"></Column> <Column field="name" header="Name"></Column>
<Column field="category" header="Category"></Column> <Column field="category" header="Category"></Column>
<Column field="quantity" header="Quantity"></Column> <Column field="quantity" header="Quantity"></Column>
@ -91,7 +91,7 @@ export default {
<Button icon="pi pi-external-link" label="Export" @click="exportCSV($event)" /> <Button icon="pi pi-external-link" label="Export" @click="exportCSV($event)" />
</div> </div>
</template> </template>
<Column field="code" header="Code"></Column> <Column field="code" header="Code" exportHeader="Product Code"></Column>
<Column field="name" header="Name"></Column> <Column field="name" header="Name"></Column>
<Column field="category" header="Category"></Column> <Column field="category" header="Category"></Column>
<Column field="quantity" header="Quantity"></Column> <Column field="quantity" header="Quantity"></Column>
@ -134,7 +134,7 @@ export default {
<p-button icon="pi pi-external-link" label="Export" @click="exportCSV($event)"></p-button> <p-button icon="pi pi-external-link" label="Export" @click="exportCSV($event)"></p-button>
</div> </div>
</template> </template>
<p-column field="code" header="Code"></p-column> <p-column field="code" header="Code" exportHeader="Product Code"></p-column>
<p-column field="name" header="Name"></p-column> <p-column field="name" header="Name"></p-column>
<p-column field="category" header="Category"></p-column> <p-column field="category" header="Category"></p-column>
<p-column field="quantity" header="Quantity"></p-column> <p-column field="quantity" header="Quantity"></p-column>