Sort By Foreign Key or Custom Column in Symfony Admin Generator use propel

Sort By Foreign Key or Custom Column in Symfony Admin Generator use propel。在admin list页面自定义的列,如何能让他也能有排序功能。

阅读 4.4k
1 个回答

自己找到方法了,分享一下。
Sorting On A Virtual Column
=================================
The new theme provides an easy way to make virtual columns and foreign key columns sortable in the list view. Just declare the corresponding fields with is_sortable to true, and the generated module will look for an orderByXXX() method in the generated query. For instance, to allow a book list to be sortable on the author name:
1.png

Then the generator will try to execute BookQuery::orderByAuthor() whenever the user clicks on the Author header to sort on this column. The method must be implemented as follows:
2.png

You can override the default sorting method name for a field by setting the sort_method parameter:
3.png

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏