diff --git a/doc/datatable/LazyLoadDoc.vue b/doc/datatable/LazyLoadDoc.vue index 9b10e2a03..75235affb 100644 --- a/doc/datatable/LazyLoadDoc.vue +++ b/doc/datatable/LazyLoadDoc.vue @@ -18,7 +18,7 @@ :value="customers" lazy paginator - :first="0" + :first="first" :rows="10" dataKey="id" :totalRecords="totalRecords" @@ -83,6 +83,7 @@ export default { customers: null, selectedCustomers: null, selectAll: false, + first: 0, filters: { name: { value: '', matchMode: 'contains' }, 'country.name': { value: '', matchMode: 'contains' }, @@ -98,7 +99,7 @@ export default { ], code: { basic: ` - @@ -109,6 +110,12 @@ export default { + @@ -119,6 +126,12 @@ export default { + @@ -128,10 +141,10 @@ export default { options: ` + @@ -168,6 +193,7 @@ export default { customers: null, selectedCustomers: null, selectAll: false, + first: 0, filters: { 'name': {value: '', matchMode: 'contains'}, 'country.name': {value: '', matchMode: 'contains'}, @@ -199,6 +225,7 @@ export default { methods: { loadLazyData() { this.loading = true; + this.lazyParams = { ...this.lazyParams, first: event?.first || this.first }; setTimeout(() => { CustomerService.getCustomers({ lazyEvent: JSON.stringify(this.lazyParams) }).then((data) => { @@ -210,15 +237,15 @@ export default { }, onPage(event) { this.lazyParams = event; - this.loadLazyData(); + this.loadLazyData(event); }, onSort(event) { this.lazyParams = event; - this.loadLazyData(); + this.loadLazyData(event); }, - onFilter() { + onFilter(event) { this.lazyParams.filters = this.filters; - this.loadLazyData(); + this.loadLazyData(event); }, onSelectAllChange(event) { const selectAll = event.checked; @@ -248,7 +275,7 @@ export default { composition: ` + @@ -269,6 +302,12 @@ export default { + @@ -301,6 +340,7 @@ const totalRecords = ref(0); const customers = ref(); const selectedCustomers = ref(); const selectAll = ref(false); +const first = ref(0); const filters = ref({ 'name': {value: '', matchMode: 'contains'}, 'country.name': {value: '', matchMode: 'contains'}, @@ -315,8 +355,9 @@ const columns = ref([ {field: 'representative.name', header: 'Representative'} ]); -const loadLazyData = () => { +const loadLazyData = (event) => { loading.value = true; + lazyParams.value = { ...lazyParams.value, first: event?.first || first.value }; setTimeout(() => { CustomerService.getCustomers({ lazyEvent: JSON.stringify(lazyParams.value) }).then((data) => { @@ -328,15 +369,15 @@ const loadLazyData = () => { }; const onPage = (event) => { lazyParams.value = event; - loadLazyData(); + loadLazyData(event); }; const onSort = (event) => { lazyParams.value = event; - loadLazyData(); + loadLazyData(event); }; -const onFilter = () => { +const onFilter = (event) => { lazyParams.value.filters = filters.value ; - loadLazyData(); + loadLazyData(event); }; const onSelectAllChange = (event) => { selectAll.value = event.checked; @@ -398,8 +439,9 @@ const onRowUnselect = () => { this.loadLazyData(); }, methods: { - loadLazyData() { + loadLazyData(event) { this.loading = true; + this.lazyParams = { ...this.lazyParams, first: event?.first || this.first }; setTimeout(() => { CustomerService.getCustomers({ lazyEvent: JSON.stringify(this.lazyParams) }).then((data) => { @@ -411,15 +453,15 @@ const onRowUnselect = () => { }, onPage(event) { this.lazyParams = event; - this.loadLazyData(); + this.loadLazyData(event); }, onSort(event) { this.lazyParams = event; - this.loadLazyData(); + this.loadLazyData(event); }, - onFilter() { + onFilter(event) { this.lazyParams.filters = this.filters; - this.loadLazyData(); + this.loadLazyData(event); }, onSelectAllChange(event) { const selectAll = event.checked;