Add delay

pull/938/head
Cagatay Civici 2021-02-02 17:40:49 +03:00
parent 18f6307ab7
commit 8636b1ee6d
1 changed files with 21 additions and 16 deletions

View File

@ -46,7 +46,6 @@
</div> </div>
<pre v-code> <pre v-code>
<code><template v-pre> <code><template v-pre>
&lt;DataTable :value="customers" :lazy="true" :paginator="true" :rows="10" :filters="filters" ref="dt"
&lt;DataTable :value="customers" :lazy="true" :paginator="true" :rows="10" :filters="filters" ref="dt" &lt;DataTable :value="customers" :lazy="true" :paginator="true" :rows="10" :filters="filters" ref="dt"
:totalRecords="totalRecords" :loading="loading" @page="onPage($event)" @sort="onSort($event)"&gt; :totalRecords="totalRecords" :loading="loading" @page="onPage($event)" @sort="onSort($event)"&gt;
&lt;Column field="name" header="Name" filterMatchMode="startsWith" ref="name" :sortable="true"&gt; &lt;Column field="name" header="Name" filterMatchMode="startsWith" ref="name" :sortable="true"&gt;
@ -119,11 +118,13 @@ export default {
loadLazyData() { loadLazyData() {
this.loading = true; this.loading = true;
this.customerService.getCustomers({lazyEvent: JSON.stringify( this.lazyParams )}).then(data => { setTimeout(() => {
this.customers = data.customers; this.customerService.getCustomers({lazyEvent: JSON.stringify( this.lazyParams )}).then(data => {
this.totalRecords = data.totalRecords; this.customers = data.customers;
this.loading = false; this.totalRecords = data.totalRecords;
}); this.loading = false;
});
}, Math.random() * 1000 + 250);
}, },
onPage(event) { onPage(event) {
this.lazyParams = event; this.lazyParams = event;
@ -252,11 +253,13 @@ export default {
loadLazyData() { loadLazyData() {
this.loading = true; this.loading = true;
this.customerService.getCustomers({lazyEvent: JSON.stringify( this.lazyParams )}).then(data => { setTimeout(() => {
this.customers = data.customers; this.customerService.getCustomers({lazyEvent: JSON.stringify( this.lazyParams )}).then(data => {
this.totalRecords = data.totalRecords; this.customers = data.customers;
this.loading = false; this.totalRecords = data.totalRecords;
}); this.loading = false;
});
}, Math.random() * 1000 + 250);
}, },
onPage(event) { onPage(event) {
this.lazyParams = event; this.lazyParams = event;
@ -298,11 +301,13 @@ export default {
loadLazyData() { loadLazyData() {
this.loading = true; this.loading = true;
this.customerService.getCustomers({lazyEvent: JSON.stringify( this.lazyParams )}).then(data => { setTimeout(() => {
this.customers = data.customers; this.customerService.getCustomers({lazyEvent: JSON.stringify( this.lazyParams )}).then(data => {
this.totalRecords = data.totalRecords; this.customers = data.customers;
this.loading = false; this.totalRecords = data.totalRecords;
}); this.loading = false;
});
}, Math.random() * 1000 + 250);
}, },
onPage(event) { onPage(event) {
this.lazyParams = event; this.lazyParams = event;