我有大量数据要显示在Buefy表中,并且正在尝试使用后端排序对列进行排序。但是当我在表中添加 backend-sorting 关键字时不会对其进行排序。如果我删除该关键字,则该表仅针对该特定页面进行排序,我有100个页面,并且需要对所有页面进行排序一起。在这里感谢一些帮助,谢谢。 (对于vue和buefy来说是全新的,在后端使用c#)
<b-table :data="data" striped hoverable paginated :loading="isLoading"
backend-pagination :total="total" :per-page="perPage" @page-change="onPageChange"
backend-sorting :default-sort="[sortField, sortOrder]" :default-sort-direction="defaultSortDirection" @sort="onSort">
methods: {
makePaging () {
let paging = {
ordering: [
{
field: this.sortField,
direction: this.sortOrder === 'asc' ? 'Ascending' : 'Descending'
}
],
filtering: [],
pageNumber: this.pageNumber - 1,
resultsPerPage: this.perPage
};
return paging;
},
async refreshData () {
this.isLoading = true;
let paging = this.makePaging();
let response = await api[API_ENDPOINT](paging);
this.res= response.data.Records;
this.total = response.data.TotalRecords;
this.isLoading = false;
},
onPageChange (newPage) {
this.pageNumber = newPage;
this.refreshData();
},
onSort (field, order) {
this.sortField = field;
this.sortOrder = order;
this.refreshData();
}
}