-
diff --git a/src/components/useconfirm/useConfirm.d.ts b/src/components/useconfirm/useconfirm.d.ts
similarity index 100%
rename from src/components/useconfirm/useConfirm.d.ts
rename to src/components/useconfirm/useconfirm.d.ts
diff --git a/src/components/useconfirm/useConfirm.js b/src/components/useconfirm/useconfirm.js
similarity index 98%
rename from src/components/useconfirm/useConfirm.js
rename to src/components/useconfirm/useconfirm.js
index 6de7503a7..c0a588441 100644
--- a/src/components/useconfirm/useConfirm.js
+++ b/src/components/useconfirm/useconfirm.js
@@ -7,6 +7,6 @@ export function useConfirm() {
if (!PrimeVueConfirm) {
throw new Error('No PrimeVue Confirmation provided!');
}
-
+
return PrimeVueConfirm;
}
\ No newline at end of file
diff --git a/src/components/usetoast/useToast.d.ts b/src/components/usetoast/usetoast.d.ts
similarity index 78%
rename from src/components/usetoast/useToast.d.ts
rename to src/components/usetoast/usetoast.d.ts
index 6854a0212..eca896906 100644
--- a/src/components/usetoast/useToast.d.ts
+++ b/src/components/usetoast/usetoast.d.ts
@@ -1 +1 @@
-export declare function useToast(): { add(args:{ severity?: string, summary?: string, detail?: string, life?: number, closable?: boolean, group?: string }): void }
\ No newline at end of file
+export declare function useToast(): { add(args:{ severity?: string, summary?: string, detail?: string, life?: number, closable?: boolean, group?: string }): void }
\ No newline at end of file
diff --git a/src/components/usetoast/useToast.js b/src/components/usetoast/usetoast.js
similarity index 97%
rename from src/components/usetoast/useToast.js
rename to src/components/usetoast/usetoast.js
index 13d019121..24713327c 100644
--- a/src/components/usetoast/useToast.js
+++ b/src/components/usetoast/usetoast.js
@@ -7,6 +7,6 @@ export function useToast() {
if (!PrimeVueToast) {
throw new Error('No PrimeVue Toast provided!');
}
-
+
return PrimeVueToast;
}
\ No newline at end of file
diff --git a/src/service/CustomerService.js b/src/service/CustomerService.js
index 2b2820713..2498173fa 100755
--- a/src/service/CustomerService.js
+++ b/src/service/CustomerService.js
@@ -18,7 +18,7 @@ export default class CustomerService {
return axios.get('demo/data/customers-xlarge.json').then(res => res.data.data);
}
- getCustomers() {
- return axios.get('https://www.primefaces.org/data/customers').then(res => res.data.customers)
+ getCustomers(params) {
+ return axios.get('https://www.primefaces.org/data/customers', { params }).then(res => res.data)
}
}
\ No newline at end of file
diff --git a/src/views/datatable/DataTableLazyDemo.vue b/src/views/datatable/DataTableLazyDemo.vue
index 74fcb6a74..2832faf56 100755
--- a/src/views/datatable/DataTableLazyDemo.vue
+++ b/src/views/datatable/DataTableLazyDemo.vue
@@ -12,12 +12,28 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -27,12 +43,28 @@
-<DataTable :value="customers" :lazy="true" :paginator="true" :rows="10"
- :totalRecords="totalRecords" :loading="loading" @page="onPage($event)">
- <Column field="name" header="Name"></Column>
- <Column field="country.name" header="Country"></Column>
- <Column field="company" header="Company"></Column>
- <Column field="representative.name" header="Representative"></Column>
+<DataTable :value="customers" :lazy="true" :paginator="true" :rows="10" :filters="filters" ref="dt"
+ :totalRecords="totalRecords" :loading="loading" @page="onPage($event)" @sort="onSort($event)">
+ <Column field="name" header="Name" filterMatchMode="startsWith" ref="name" :sortable="true">
+ <template #filter>
+ <InputText type="text" v-model="filters['name']" @keydown="onFilter($event)" class="p-column-filter" placeholder="Search by name"/>
+ </template>
+ </Column>
+ <Column field="country.name" header="Country" filterField="country.name" filterMatchMode="contains" ref="country.name" :sortable="true">
+ <template #filter>
+ <InputText type="text" v-model="filters['country.name']" @keydown="onFilter($event)" class="p-column-filter" placeholder="Search by country"/>
+ </template>
+ </Column>
+ <Column field="company" header="Company" filterMatchMode="contains" ref="company" :sortable="true">
+ <template #filter>
+ <InputText type="text" v-model="filters['company']" @keydown="onFilter($event)" class="p-column-filter" placeholder="Search by company"/>
+ </template>
+ </Column>
+ <Column field="representative.name" header="Representative" filterField="representative.name" filterMatchMode="contains" ref="representative.name" :sortable="true">
+ <template #filter>
+ <InputText type="text" v-model="filters['representative.name']" @keydown="onFilter($event)" class="p-column-filter" placeholder="Search by representative"/>
+ </template>
+ </Column>
</DataTable>
@@ -46,10 +78,17 @@ export default {
return {
loading: false,
totalRecords: 0,
- customers: null
+ customers: null,
+ filters: {},
+ lazyFilters: {},
+ columns: [
+ {field: 'name', header: 'Name'},
+ {field: 'country.name', header: 'Country'},
+ {field: 'company', header: 'Company'},
+ {field: 'representative.name', header: 'Representative'}
+ ]
}
},
- datasource: null,
customerService: null,
created() {
this.customerService = new CustomerService();
@@ -57,23 +96,76 @@ export default {
mounted() {
this.loading = true;
- setTimeout(() => {
- this.customerService.getCustomers().then(data => {
- this.datasource = data;
- this.totalRecords = data.length,
- this.customers = this.datasource.slice(0, 10);
- this.loading = false;
- });
- }, 500);
+ this.customerService.getCustomers({lazyEvent: JSON.stringify({first: 0, rows: this.$refs.dt.rows})}).then(data => {
+ this.customers = data.customers;
+ this.totalRecords = data.totalRecords;
+ this.loading = false;
+ });
+
+ const filters = {};
+ for(let i=0; i < this.columns.length; i++) {
+ let obj = {};
+ obj["matchMode"] = this.$refs[this.columns[i].field].filterMatchMode || "startsWith";
+ obj["value"] = null;
+ filters[this.columns[i].field] = obj;
+ }
+
+ this.lazyFilters = filters;
},
methods: {
- onPage(event) {
+ onLazyEvent(event) {
+ const proxyFilters = JSON.parse(JSON.stringify(this.filters));
+ for(let filter in proxyFilters) {
+ this.lazyFilters[filter].value = proxyFilters[filter] || null;
+ }
+
this.loading = true;
+ let params = {
+ first: event.first,
+ rows: event.rows,
+ sortField: event.sortField,
+ sortOrder: event.sortOrder,
+ filters: this.lazyFilters
+ };
setTimeout(() => {
- this.customers = this.datasource.slice(event.first, event.first + event.rows);
- this.loading = false;
- }, 500);
+ this.customerService.getCustomers({lazyEvent: JSON.stringify( params )}).then(data => {
+ this.customers = data.customers;
+ this.totalRecords = data.totalRecords;
+ this.loading = false;
+ });
+ }, 1000);
+ },
+ onPage(event) {
+ this.onLazyEvent(event);
+ },
+ onSort(event) {
+ this.onLazyEvent(event);
+ },
+ onFilter(event) {
+ if(event.keyCode === 13) {
+ const proxyFilters = JSON.parse(JSON.stringify(this.filters));
+ for(let filter in proxyFilters) {
+ this.lazyFilters[filter].value = proxyFilters[filter] || null;
+ }
+
+ this.loading = true;
+ let params = {
+ first: 0,
+ rows: this.$refs.dt.rows,
+ sortField: null,
+ sortOrder: null,
+ filters: this.lazyFilters
+ };
+
+ setTimeout(() => {
+ this.customerService.getCustomers({lazyEvent: JSON.stringify( params )}).then(data => {
+ this.customers = data.customers;
+ this.totalRecords = data.totalRecords;
+ this.loading = false;
+ });
+ }, 1000);
+ }
}
}
}
@@ -93,10 +185,17 @@ export default {
return {
loading: false,
totalRecords: 0,
- customers: null
+ customers: null,
+ filters: {},
+ lazyFilters: {},
+ columns: [
+ {field: 'name', header: 'Name'},
+ {field: 'country.name', header: 'Country'},
+ {field: 'company', header: 'Company'},
+ {field: 'representative.name', header: 'Representative'}
+ ]
}
},
- datasource: null,
customerService: null,
created() {
this.customerService = new CustomerService();
@@ -104,23 +203,77 @@ export default {
mounted() {
this.loading = true;
- setTimeout(() => {
- this.customerService.getCustomers().then(data => {
- this.datasource = data;
- this.totalRecords = data.length,
- this.customers = this.datasource.slice(0, 10);
- this.loading = false;
- });
- }, 500);
+ this.customerService.getCustomers({lazyEvent: JSON.stringify({first: 0, rows: this.$refs.dt.rows})}).then(data => {
+ this.customers = data.customers;
+ this.totalRecords = data.totalRecords;
+ this.loading = false;
+ });
+
+ const filters = {};
+ for(let i=0; i {
- this.customers = this.datasource.slice(event.first, event.first + event.rows);
- this.loading = false;
- }, 500);
+ this.customerService.getCustomers({lazyEvent: JSON.stringify( params )}).then(data => {
+ this.customers = data.customers;
+ this.totalRecords = data.totalRecords;
+ this.loading = false;
+ });
+ }, 1000);
+ },
+ onPage(event) {
+ this.onLazyEvent(event);
+ },
+ onSort(event) {
+ this.onLazyEvent(event);
+ },
+ onFilter(event) {
+ if(event.keyCode === 13) {
+ // proxy to object
+ const proxyFilters = JSON.parse(JSON.stringify(this.filters));
+ for(let filter in proxyFilters) {
+ this.lazyFilters[filter].value = proxyFilters[filter] || null;
+ }
+
+ this.loading = true;
+ let params = {
+ first: 0,
+ rows: this.$refs.dt.rows,
+ sortField: null,
+ sortOrder: null,
+ filters: this.lazyFilters
+ };
+
+ setTimeout(() => {
+ this.customerService.getCustomers({lazyEvent: JSON.stringify( params )}).then(data => {
+ this.customers = data.customers;
+ this.totalRecords = data.totalRecords;
+ this.loading = false;
+ });
+ }, 1000);
+ }
}
}
}
diff --git a/src/views/setup/Setup.vue b/src/views/setup/Setup.vue
index c07b460ca..84c595a65 100755
--- a/src/views/setup/Setup.vue
+++ b/src/views/setup/Setup.vue
@@ -63,11 +63,11 @@ app.component('Dialog', Dialog);
<meta charset="utf-8">
<title>calendar demo</title>
-<link href="https://unpkg.com/primevue/resources/themes/saga-blue/theme.css " rel="stylesheet">
+<link href="https://unpkg.com/primevue/resources/themes/saga-blue/theme.css" rel="stylesheet">
<link href="https://unpkg.com/primevue/resources/primevue.min.css " rel="stylesheet">
-<link href="https://unpkg.com/primeicons/primeicons.css " rel="stylesheet">
+<link href="https://unpkg.com/primeicons/primeicons.css" rel="stylesheet">
<script src="https://unpkg.com/vue@next"></script>
-<script src="https://unpkg.com/primevue/components/calendar/calendar.umd.min.js"></script>
+<script src="https://unpkg.com/primevue/calendar/calendar.umd.min.js"></script>
<div id="app">
<p-calendar></p-calendar>