自己找到方法了,分享一下。
在虛擬列上排序
===================================
新主題提供了一種使虛擬列和外鍵列在清單檢視中可排序的簡單方法。只需在產生的查詢中使用 is_sortable to true, and the generated module will look for an orderByXXX() 方法聲明對應的欄位即可。例如,允許按作者姓名對書籍清單進行排序:
然後產生器將嘗試執行BookQuery::orderByAuthor() whenever the user clicks on the Author header 對此列進行排序。方法必須實作如下:
自己找到方法了,分享一下。
在虛擬列上排序
===================================
新主題提供了一種使虛擬列和外鍵列在清單檢視中可排序的簡單方法。只需在產生的查詢中使用
is_sortable
totrue
, and the generated module will look for anorderByXXX()
方法聲明對應的欄位即可。例如,允許按作者姓名對書籍清單進行排序:然後產生器將嘗試執行
BookQuery::orderByAuthor()
whenever the user clicks on theAuthor
header 對此列進行排序。方法必須實作如下:您可以透過設定
sort_method
參數來覆寫欄位的預設排序方法名稱: