Fixed #1042 - DataTable "select all checkbox" and "export csv" exclude frozen rows

pull/1073/head
Cagatay Civici 2021-03-10 12:36:09 +03:00
parent 301781e3e0
commit 7c9e6234c7
1 changed files with 8 additions and 8 deletions

View File

@ -815,7 +815,7 @@ export default {
toggleRowsWithCheckbox(event) { toggleRowsWithCheckbox(event) {
const processedData = this.processedData; const processedData = this.processedData;
const checked = this.allRowsSelected; const checked = this.allRowsSelected;
const _selection = checked ? [] : (processedData ? [...processedData] : [...this.value]); const _selection = checked ? [] : (this.frozenValue ? [...this.frozenValue, ...processedData]: processedData);
this.$emit('update:selection', _selection); this.$emit('update:selection', _selection);
if (checked) if (checked)
@ -931,9 +931,10 @@ export default {
let data = this.processedData; let data = this.processedData;
let csv = '\ufeff'; let csv = '\ufeff';
if (options && options.selectionOnly) { if (options && options.selectionOnly)
data = this.selection || []; data = this.selection || [];
} else if (this.frozenValue)
data = data ? [...this.frozenValue, ...data] : this.frozenValue;
//headers //headers
let headerInitiated = false; let headerInitiated = false;
@ -1707,7 +1708,7 @@ export default {
}, },
processedData() { processedData() {
if (this.lazy) { if (this.lazy) {
return this.value; return this.value || [];
} }
else { else {
if (this.value && this.value.length) { if (this.value && this.value.length) {
@ -1726,9 +1727,8 @@ export default {
return data; return data;
} }
else {
return null; return [];
}
} }
}, },
dataToRender() { dataToRender() {
@ -1768,7 +1768,7 @@ export default {
return ['p-datatable-loading-icon pi-spin', this.loadingIcon]; return ['p-datatable-loading-icon pi-spin', this.loadingIcon];
}, },
allRowsSelected() { allRowsSelected() {
const val = this.processedData; const val = this.frozenValue ? [...this.frozenValue, ...this.processedData]: this.processedData;
return (val && val.length > 0 && this.selection && this.selection.length > 0 && this.selection.length === val.length); return (val && val.length > 0 && this.selection && this.selection.length > 0 && this.selection.length === val.length);
}, },
attributeSelector() { attributeSelector() {