From 5319c59d010cc38d6a79f02529dd4c9ff610ced1 Mon Sep 17 00:00:00 2001
From: Cagatay Civici
Lazy mode is handy to deal with large datasets, instead of loading the entire data, small chunks of data is loaded by invoking corresponding callbacks such as paging and sorting. Sample belows imitates lazy paging by using an in memory list. - It is also important to assign the logical number of rows to totalRecords by doing a projection query for paginator configuration so that paginator displays the UI - assuming there are actually records of totalRecords size although in reality they aren't as in lazy mode, only the records that are displayed on the current page exist.
+Lazy mode is handy to deal with large datasets, instead of loading the entire data, small chunks of data is loaded by invoking corresponding callbacks such as paging and sorting. + It is also important to assign the logical number of rows to totalRecords by doing a projection query for paginator configuration so that paginator displays the UI accordingly.
-Lazy loading is implemented by handling pagination and sorting using page and sort events by making a remote query using the information - passed to the events such as first offset, number of rows and sort field for ordering. Filtering is handled differently as filter elements are defined using templates. filter event is not triggered in - lazy mode instead use the event you prefer on your form elements such as input, change, blur to make a remote call by passing the filters property to update the displayed data. Note that, - in lazy filtering, totalRecords should also be updated to align the data with the paginator.
+Lazy loading is implemented by handling page, sort, filter events by making a remote query using the information + passed to these events such as first offset, number of rows, sort field for ordering and filters. Note that, in lazy filtering totalRecords should also be updated to align the data with the paginator.
-Here is a sample paging implementation with in memory data, a more enhanced example with a backend is being worked on and will be available at a github repository.
-
-<DataTable :value="cars" :lazy="true" :paginator="true" :rows="10"
- :totalRecords="totalRecords" :loading="loading" @page="onPage($event)">
- <Column field="vin" header="Vin"></Column>
- <Column field="year" header="Year"></Column>
- <Column field="brand" header="Brand"></Column>
- <Column field="color" header="Color"></Column>
-</DataTable>
-
-
-
-
-import CarService from '../../service/CarService';
-
-export default {
- data() {
- return {
- loading: false,
- totalRecords: 0,
- cars: null
- }
- },
- datasource: null,
- carService: null,
- created() {
- this.carService = new CarService();
- },
- mounted() {
- this.loading = true;
-
- setTimeout(() => {
- this.carService.getCarsLarge().then(data => {
- this.datasource = data;
- this.totalRecords = data.length,
- this.cars = this.datasource.slice(0, 10);
- this.loading = false;
- });
- }, 1000);
- },
- methods: {
- onPage(event) {
- this.loading = true;
-
- setTimeout(() => {
- this.cars = this.datasource.slice(event.first, event.first + event.rows);
- this.loading = false;
- }, 1000);
- }
- }
-}
-
-
+ Visit the
Rows can be expanded to display additional content using the expandedRows property with the v-model directive accompanied by a template named "expansion". row-expand and row-collapse are optional callbacks that are invoked when a row is expanded or toggled.
@@ -2285,8 +2230,7 @@ export default { event.sortOrder: Sort order as integer