As said by me in Ticket #924, I would further enhance the capabilities of a list by adding the option to make a list a multi-sort list and that is what I will upload in this ticket.
You can now set in your generator.yml file that the list is a multisort list and the result will be a list which can sort on multiple columns (for example first on product-category (which is a foreign-table) than on the product-names, by clicking on the column-headers one by one. Resetting the ordening can be done file the reset button of the filter. Removing one column from the sorting can be done by the X which will appear in the columns on which you sort.
Enabling the multisort is now as simple as setting multisort: true in the generator.yml file. A complete overview of a generator.yml file, with foreign-columns on which you want to sort alfabetically (instead of on id-value) will be:
generator:
class: sfPropelAdminGenerator
param:
model_class: Product
theme: default
fields:
productgroupid: { name: Productgroup }
list:
title: Products
display: [=productname, description, productgroup]
multisort: true
fields:
productgroup:
name: Productgroup
join_fields: [ProductPeer::PRODUCTGROUPID, ProductgroupPeer::PRODUCTGROUPID]
sort_column: [ProductgroupPeer::TITLE]
filters: [productgroupid]
I've changed the following files from the theme:
- _list_th_tabular.php
- added a X to remove the sorting from a column
- action.class.php (this was rewritten for a big part, now arrays are used to keep track of the columns to sort on)
- processSort() set an array, instead of only one sort-field
- addSortCriteria() do the sorting on all fields in the array
- processFilters() to reset the sorting completely
attached you can find the source