design vue 表格開啟列排序的操作
開啟排序
1、本地數(shù)據(jù)排序
column數(shù)據(jù)設置,需要開啟的列設置sorter: (a, b) => a.address.length - b.address.length, 自定義排序方法
2、服務端排序sorter設置true
點擊排序,表格觸發(fā)change方法,接受參數(shù)
change (pagination, filters, sorter, { currentDataSource })
第三個參數(shù)就是排序信息
{field, order}
<a-table :columns='header' :dataSource='body' :pagination='pagination' @change='handleTableChange' > methods: { handleTableChange (pagination, filters, {field, order}) { this.sort = { field: field || ’’, order: order || ’’ } this.pagination.current = pagination.current this.getList() },}
如何設置第一次點擊是降序
ant design vue 表格排序,默認點擊排序順序是[升序,降序,不排序] 如此循環(huán)
如何設置先降序后升序呢,api文檔有提到
1、可以在column的每一項設置sortDirections: [’descend’, ’ascend’]
2、在表格直接設置sortDirections
<a-table :columns='header' :dataSource='body' :pagination='pagination' @change='handleTableChange' :sortDirections='[’descend’, ’ascend’]' // 這里 >
3、用[’descend’ | ’ascend’]寫法不行,用數(shù)組[’descend’, ’ascend’]
4、設置defaultSortOrder沒有效果
補充知識:Ant Design Vue實現(xiàn)的表格排序點擊第三次取消排序的解決方法
以上這篇design vue 表格開啟列排序的操作就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持好吧啦網。
相關文章:
1. 基于javaweb+jsp實現(xiàn)學生宿舍管理系統(tǒng)2. 多級聯(lián)動下拉選擇框,動態(tài)獲取下一級3. ASP.NET MVC實現(xiàn)樹形導航菜單4. 如何封裝一個Ajax函數(shù)5. Java 接口和抽象類的區(qū)別詳解6. Laravel Eloquent ORM高級部分解析7. IDEA 搭建maven 安裝、下載、配置的圖文教程詳解8. jsp response.sendRedirect()用法詳解9. Spring security 自定義過濾器實現(xiàn)Json參數(shù)傳遞并兼容表單參數(shù)(實例代碼)10. PHP擴展之URL編碼、解碼及解析——URLs
