Current Status of Sorting Reference Data in HTML Select List
Sorting of reference data is made simply with the PHP function "uasort()" based on the displayed item. The sorting is made more times at different places:
- lib/venture/util/BusinessObjectSetBase.php - function setMenu()
- lib/venture/util/FormFieldSelectBase.php - function htmlOptions()
If the data is read directly from the database, not from cache, it is sorted in the SQL select, by the order clause. E.g. in the case of revisionNo:
- app/model/RevisionsSet.php - function getRevisionByCodeNo()
Problems
The simple sorting alphabetically is not good in many cases, where the code in the reference table not causes the desired sort order. E.g. in the case of revisionTypeId the wrong sorting:
A - As Built - Ahogy elkészült B - Bid - Ajánlat C - Construction - Kivitelezés D - Design - Tervezés P - Planning - Ütemezés
It should be:
B - Bid - Ajánlat C - Construction - Kivitelezés D - Design - Tervezés P - Planning - Ütemezés A - As Built - Ahogy elkészült
Solutions
Current But Nasty Solution
In the files, mentioned above, depending on the fieldname the sorting is jumped over, to achieve, that the data appaers in the order as it is defined in the database. This type of PATCH is logged also in the log file:
Jan 14 17:22:35 drawmgt-met [info] BOSet:setMenu: PATCH - sorting is switched off: revisionTypeId Jan 14 17:19:46 drawmgt-met [info] FormFieldSelectBase:htmlOptions: PATCH - sorting is switched off: revisionTypeId
Future Solution
Sort order should be defined by a new field sortOrder in the reference tables.
Perhaps we should have also a languageId in the reference tables, to display reference data only in the language of the user.