javascript - Buefy 表后端排序似乎不起作用
问题描述
我有大量数据要显示在 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();
}
}
解决方案
推荐阅读
- python - 从 yyyy-mm-dd 到 dd:mm:yyyy 的日期格式转换
- angular - 枚举无法识别 - cypress 角度单元测试
- c++ - 在 C++ 中迭代二维向量时出现超出范围的错误
- javascript - 使用功能挂钩反应 Redux(无法访问道具上的动作创建者方法)
- c - *C* 我一直在 Leetcode 中遇到 Address Sanitizer Heap Buffer Overflow
- python - 在 urls.py(Django) 中未检测到 TodayArchiveview
- reactjs - 为什么 post man 中的 api 请求和 react native 中的 api fetch 请求有不同的响应
- html - 导航栏列表未居中
- python - 如何合并使用openslide-python获得的图块
- python - 为什么 Python 中负数的平方根不是纯虚数?