From 1a0f0fe2074ceec43a9f688d490b409fe1943bce Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 21 Nov 2018 23:54:23 +0000 Subject: [PATCH] --- app/ayanova/src/components/widgetlist.vue | 60 ++++++++++++++++++----- 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/app/ayanova/src/components/widgetlist.vue b/app/ayanova/src/components/widgetlist.vue index ebaa07b3..c9ad7372 100644 --- a/app/ayanova/src/components/widgetlist.vue +++ b/app/ayanova/src/components/widgetlist.vue @@ -35,7 +35,6 @@ export default { { text: "Widget", align: "left", - sortable: false, value: "name" }, { text: "Serial", value: "serial" }, @@ -49,22 +48,33 @@ export default { watch: { pagination: { handler() { - this.getDataFromApi().then(data => { - this.Items = data.items; - this.totalItems = data.total; - }); + this.getDataFromApi(); + /* + { + descending: false, + page: 1, + rowsPerPage: 5, + sortBy: "name", + totalItems: 0 + } + */ + // this.getDataFromApi().then(data => { + // this.Items = data.items; + // this.totalItems = data.total; + // }); }, deep: true } }, mounted() { - this.loading = true; - pagedList.fetch("Widget/ListWidgets", { Offset: 5, Limit: 5 }).then(res => { - // debugger; - this.loading = false; - this.Items = res.data; - this.totalItems = res.paging.count; - }); + this.getDataFromApi(); + // this.loading = true; + // pagedList.fetch("Widget/ListWidgets", { Offset: 5, Limit: 5 }).then(res => { + // // debugger; + // this.loading = false; + // this.Items = res.data; + // this.totalItems = res.paging.count; + // }); // this.getDataFromApi().then(data => { // this.Items = data.items; @@ -72,6 +82,32 @@ export default { // }); }, methods: { + getDataFromApi() { + var listOptions = { + Offset: 0, + Limit: 5 + }; + + if (this.pagination.rowsPerPage) { + listOptions.Limit = this.pagination.rowsPerPage; + } + + if (this.pagination.page) { + if (this.pagination.page > 0) { + listOptions.Offset = this.pagination.page * listOptions.Limit; + } else { + listOptions.Offset = 0; + } + } + + this.loading = true; + pagedList.fetch("Widget/ListWidgets", listOptions).then(res => { + // debugger; + this.loading = false; + this.Items = res.data; + this.totalItems = res.paging.count; + }); + } // getDataFromApi() { // //http://localhost:7575/api/v8.0/Widget/ListWidgets?Offset=5&Limit=5 // this.loading = true;