This commit is contained in:
2021-02-01 22:37:40 +00:00
parent 7713575f55
commit 67cd3ccbf2

View File

@@ -3,7 +3,7 @@
<gz-error :errorBoxMessage="formState.errorBoxMessage"></gz-error>
<v-card>
{{ dataTablePagingOptions }}
{{ headers }}
<v-card-title>
<v-select
v-model="listViewId"
@@ -464,8 +464,8 @@ export default {
if (sortHasChanged && !this.loading) {
//update sort at server and then allow get data
console.log("1 calling api method");
//this would normally never fail and no return data is required here
//no return data is required here
//because getdatafromapi will have the data to refresh the sort of the view anyway
//so it's fire and forget
await window.$gz.api.post("data-list-column-view/sort", {
@@ -476,7 +476,7 @@ export default {
sortDesc: this.dataTablePagingOptions.sortDesc
});
}
console.log("2 About to call getdata from api");
//has changed something important so refetch and put a pin in last paging settings for next time
this.getDataFromApi();
this.lastDataTablePagingOptions = this.dataTablePagingOptions;
@@ -517,6 +517,27 @@ export default {
});
},
setSortIndicatorsFromDataListResponse(rsort) {
let sortBy = [];
let sortDesc = [];
if (rsort != null) {
Object.keys(rsort).forEach((key, index) => {
//Pull column header name "value" from "fk"matching "key" here from this.headers columns.c0 etc here from this.headers see above method
sortBy.push(this.headers.find(z => z.fk == key).value);
//if not null then push into the sortBy array
let sort = rsort[key];
if (sort == "-") {
sortDesc.push(true);
} else {
sortDesc.push(false);
}
// console.log(`${key}: ${rsort[key]}`);
});
}
//vm.selected = [...preSelected];
this.dataTablePagingOptions.sortBy = [...sortBy];
this.dataTablePagingOptions.sortDesc = [...sortDesc];
console.log("setsortindicator:", { sortBy: sortBy, sortDesc: sortDesc });
// {
// "sortBy": {
// "customername": "-",
@@ -524,6 +545,10 @@ export default {
// "customeremail": "-"
// }
// }
//to this
//
//this.dataTablePagingOptions.sortDesc
//{ "page": 1, "itemsPerPage": 10, "sortBy": [ "columns.c0", "columns.c1", "columns.c2" ], "sortDesc": [ false, false, true ], "groupBy": [], "groupDesc": [], "mustSort": false, "multiSort": true }
},
refresh() {
this.getDataFromApi();