Update paginator on filtering
parent
9e873b5d5b
commit
246199ca51
|
@ -35,7 +35,7 @@
|
||||||
</tfoot>
|
</tfoot>
|
||||||
<tbody class="p-datatable-tbody">
|
<tbody class="p-datatable-tbody">
|
||||||
<template v-if="!empty">
|
<template v-if="!empty">
|
||||||
<tr class="p-datatable-row" v-for="(rowData, index) of data" :key="getRowKey(rowData, index)">
|
<tr class="p-datatable-row" v-for="(rowData, index) of dataToRender" :key="getRowKey(rowData, index)">
|
||||||
<td v-for="(col,i) of columns" :key="col.columnKey||col.field||i" :style="col.bodyStyle" :class="col.bodyClass">
|
<td v-for="(col,i) of columns" :key="col.columnKey||col.field||i" :style="col.bodyStyle" :class="col.bodyClass">
|
||||||
<ColumnSlot :data="rowData" :column="col" type="body" v-if="col.$scopedSlots.body" />
|
<ColumnSlot :data="rowData" :column="col" type="body" v-if="col.$scopedSlots.body" />
|
||||||
<template v-else>{{resolveFieldData(rowData, col.field)}}</template>
|
<template v-else>{{resolveFieldData(rowData, col.field)}}</template>
|
||||||
|
@ -431,7 +431,7 @@ export default {
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
},
|
},
|
||||||
data() {
|
processedData() {
|
||||||
if (this.value && this.value.length) {
|
if (this.value && this.value.length) {
|
||||||
let data = this.value;
|
let data = this.value;
|
||||||
|
|
||||||
|
@ -446,24 +446,31 @@ export default {
|
||||||
data = this.filter(data);
|
data = this.filter(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.paginator) {
|
return data;
|
||||||
const first = this.lazy ? 0 : this.d_first;
|
|
||||||
return data.slice(first, first + this.d_rows);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
dataToRender() {
|
||||||
|
const data = this.processedData;
|
||||||
|
|
||||||
|
if (this.paginator) {
|
||||||
|
const first = this.lazy ? 0 : this.d_first;
|
||||||
|
return data.slice(first, first + this.d_rows);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
},
|
||||||
totalRecordsLength() {
|
totalRecordsLength() {
|
||||||
if (this.totalRecords)
|
if (this.lazy) {
|
||||||
return this.totalRecords;
|
return this.totalRecords;
|
||||||
else
|
}
|
||||||
return this.value ? this.value.length : 0;
|
else {
|
||||||
|
const data = this.hasFilters ? this.processedData : this.value;
|
||||||
|
return data ? data.length : 0;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
empty() {
|
empty() {
|
||||||
return (!this.value || this.value.length === 0);
|
return (!this.value || this.value.length === 0);
|
||||||
|
|
Loading…
Reference in New Issue