Merge branch 'feature/tt-table-fix-excel-export' into 'master'
fixed excel export to only show filtered rows See merge request fronk/thetool!528
This commit is contained in:
@@ -172,7 +172,7 @@ Vue.component('tt-table', {
|
||||
style="height: 150px">
|
||||
<td :colspan="Object.keys(columns).length" class="text-center">Laden...</td>
|
||||
</tr>
|
||||
<template v-for="(row, index) in (ssr === false ? computedRows : rows)">
|
||||
<template v-for="(row, index) in (ssr === false ? visibleRows : rows)">
|
||||
<tr :class="typeof config.customRowClass === 'function' ? config.customRowClass(row) : ''"
|
||||
@click="$emit('row-click', row)"
|
||||
>
|
||||
@@ -467,7 +467,6 @@ Vue.component('tt-table', {
|
||||
} else if (this.columns[key] && this.columns[key].filter === 'date') {
|
||||
parsedRow[this.columns[key].text] = this.moment(row[key]).format('DD.MM.YYYY HH:mm');
|
||||
} else {
|
||||
console.log(key)
|
||||
parsedRow[this.columns[key].text] = row[key];
|
||||
}
|
||||
|
||||
@@ -480,8 +479,8 @@ Vue.component('tt-table', {
|
||||
|
||||
|
||||
let data = typeof this.config.customExcelProcessor === 'function' ?
|
||||
this.config.customExcelProcessor(JSON.parse(JSON.stringify(this.rawRows))) :
|
||||
defaultExcelProcessor.call(this, JSON.parse(JSON.stringify(this.rawRows)));
|
||||
this.config.customExcelProcessor(JSON.parse(JSON.stringify(this.computedRows))) :
|
||||
defaultExcelProcessor.call(this, JSON.parse(JSON.stringify(this.computedRows)));
|
||||
|
||||
const ws = this.window.XLSX.utils.json_to_sheet(data);
|
||||
|
||||
@@ -777,16 +776,19 @@ Vue.component('tt-table', {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// console.timeEnd('Filtering and pagination');
|
||||
return output;
|
||||
},
|
||||
visibleRows() {
|
||||
if (!this.rawRows || this.ssr === true) return null;
|
||||
// Pagination and slice logic
|
||||
this.pagination.total_pages = Math.ceil(output.length / this.pagination.per_page);
|
||||
this.pagination.filtered_available = output.length;
|
||||
this.pagination.total_pages = Math.ceil(this.computedRows.length / this.pagination.per_page);
|
||||
this.pagination.filtered_available = this.computedRows.length;
|
||||
const perPage = this.pagination.per_page;
|
||||
const page = this.pagination.page;
|
||||
const startIndex = (page - 1) * perPage;
|
||||
const endIndex = startIndex + perPage;
|
||||
this.rows = output.slice(startIndex, Math.min(endIndex, output.length));
|
||||
this.rows = this.computedRows.slice(startIndex, Math.min(endIndex, this.computedRows.length));
|
||||
return this.rows;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user