Tuning for lazy loading
parent
7cc6de6fb8
commit
62e2c0f8c1
|
@ -847,24 +847,29 @@ export default {
|
||||||
return [];
|
return [];
|
||||||
},
|
},
|
||||||
processedData() {
|
processedData() {
|
||||||
if (this.value && this.value.length) {
|
if (this.lazy) {
|
||||||
let data = this.value;
|
return this.value;
|
||||||
|
|
||||||
if (this.sorted) {
|
|
||||||
if(this.sortMode === 'single')
|
|
||||||
data = this.sortSingle(data);
|
|
||||||
else if(this.sortMode === 'multiple')
|
|
||||||
data = this.sortMultiple(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.hasFilters) {
|
|
||||||
data = this.filter(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return null;
|
if (this.value && this.value.length) {
|
||||||
|
let data = this.value;
|
||||||
|
|
||||||
|
if (this.sorted) {
|
||||||
|
if(this.sortMode === 'single')
|
||||||
|
data = this.sortSingle(data);
|
||||||
|
else if(this.sortMode === 'multiple')
|
||||||
|
data = this.sortMultiple(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.hasFilters) {
|
||||||
|
data = this.filter(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dataToRender() {
|
dataToRender() {
|
||||||
|
@ -888,7 +893,8 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
empty() {
|
empty() {
|
||||||
return (!this.value || this.value.length === 0);
|
const data = this.processedData;
|
||||||
|
return (!data || data.length === 0);
|
||||||
},
|
},
|
||||||
paginatorTop() {
|
paginatorTop() {
|
||||||
return this.paginator && (this.paginatorPosition !== 'bottom' || this.paginatorPosition === 'both');
|
return this.paginator && (this.paginatorPosition !== 'bottom' || this.paginatorPosition === 'both');
|
||||||
|
|
|
@ -318,7 +318,7 @@ export default {
|
||||||
<p>Lazy loading is implemented by handling pagination, sorting and filtering using their own page, sort and filter events in addition to enabling lazy property. Here is a sample paging implementation with in memory data.</p>
|
<p>Lazy loading is implemented by handling pagination, sorting and filtering using their own page, sort and filter events in addition to enabling lazy property. Here is a sample paging implementation with in memory data.</p>
|
||||||
<CodeHighlight>
|
<CodeHighlight>
|
||||||
<template v-pre>
|
<template v-pre>
|
||||||
<DataTable :value="cars" :lazy="true" paginator="true" :rows="10"
|
<DataTable :value="cars" :lazy="true" :paginator="true" :rows="10"
|
||||||
:totalRecords="totalRecords" :loading="loading" @page="onPage($event)">
|
:totalRecords="totalRecords" :loading="loading" @page="onPage($event)">
|
||||||
<Column field="vin" header="Vin"></Column>
|
<Column field="vin" header="Vin"></Column>
|
||||||
<Column field="year" header="Year"></Column>
|
<Column field="year" header="Year"></Column>
|
||||||
|
|
|
@ -44,6 +44,9 @@
|
||||||
<MultiSelect v-model="filters['color']" :options="colors" optionLabel="name" optionValue="value" placeholder="Select a Color" />
|
<MultiSelect v-model="filters['color']" :options="colors" optionLabel="name" optionValue="value" placeholder="Select a Color" />
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
|
<template #empty>
|
||||||
|
No records found.
|
||||||
|
</template>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -86,6 +89,9 @@
|
||||||
<MultiSelect v-model="filters['color']" :options="colors" optionLabel="name" optionValue="value" placeholder="Select a Color" />
|
<MultiSelect v-model="filters['color']" :options="colors" optionLabel="name" optionValue="value" placeholder="Select a Color" />
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
|
<template #empty>
|
||||||
|
No records found.
|
||||||
|
</template>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
</template>
|
</template>
|
||||||
</CodeHighlight>
|
</CodeHighlight>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content-section implementation">
|
<div class="content-section implementation">
|
||||||
<DataTable :value="cars" :lazy="true" paginator="true" :rows="10"
|
<DataTable :value="cars" :lazy="true" :paginator="true" :rows="10"
|
||||||
:totalRecords="totalRecords" :loading="loading" @page="onPage($event)">
|
:totalRecords="totalRecords" :loading="loading" @page="onPage($event)">
|
||||||
<Column field="vin" header="Vin"></Column>
|
<Column field="vin" header="Vin"></Column>
|
||||||
<Column field="year" header="Year"></Column>
|
<Column field="year" header="Year"></Column>
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
<TabPanel header="Source">
|
<TabPanel header="Source">
|
||||||
<CodeHighlight>
|
<CodeHighlight>
|
||||||
<template v-pre>
|
<template v-pre>
|
||||||
<DataTable :value="cars" :lazy="true" paginator="true" :rows="10"
|
<DataTable :value="cars" :lazy="true" :paginator="true" :rows="10"
|
||||||
:totalRecords="totalRecords" :loading="loading" @page="onPage($event)">
|
:totalRecords="totalRecords" :loading="loading" @page="onPage($event)">
|
||||||
<Column field="vin" header="Vin"></Column>
|
<Column field="vin" header="Vin"></Column>
|
||||||
<Column field="year" header="Year"></Column>
|
<Column field="year" header="Year"></Column>
|
||||||
|
|
Loading…
Reference in New Issue