Welcome, Guest
Username: Password: Remember me

TOPIC: Ordering of foreign key data in drop downs

Ordering of foreign key data in drop downs 03 Dec 2015 16:36 #13719

  • Ferm
  • Ferm's Avatar
  • Offline
  • Junior Member
  • Posts: 39
  • Thank you received: 6
  • Karma: 2
When I use a foreign key in a table, the records of the "foreign table" will be shown as drop downs in combo box filters in the list view and also in forms in the item view.

In both those situations, I can choose to use ajax loading or not. In my opinion, there are two problems:

1. The sorting is different. If I use the ordering wizard in the foreign table, the records will be shown as I order them with the ordering wizard only if I use ajax loading. If not, the records of the foreign table are always sorted alphabetically. So if my "foreign" table has the records A,B,C but he ordering is A,C,B, switching on ajax loading will give you A,C,B for the drop-down and without ajax it will be A,B,C
2. Small problem but in the item view, the design is different depending on whether I use ajax loading or not. For filters in the list view, it is always the same.

I would be really grateful if someone could help me figure out how to fix the ordering problem without using ajax loading. In my opinion, the problem is a rouge $this->addOrder() in the in the display function so it is possible to fork but you need to fork every view/layout combination.
The administrator has disabled public write access.

Ordering of foreign key data in drop downs 07 Dec 2015 15:06 #13732

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
You can override the protected function prepareQuery(&$query) of the FK table.
Add an order there.
The administrator has disabled public write access.
Time to create page: 0.102 seconds

Get Started