Welcome, Guest
Username: Password: Remember me

TOPIC: ordering of combo

ordering of combo 07 Nov 2013 15:21 #11547

  • ewajoom
  • ewajoom's Avatar
  • Offline
  • Junior Member
  • Posts: 36
  • Thank you received: 2
  • Karma: 0
Hi,

Is it possible to order combo lists a I want ? (it seems to be ordered by name, for one combo I want it ordered by ordering value)
? (I think it could be a good improvement to have an "order by" properties in builder)

thanks!
The administrator has disabled public write access.

ordering of combo 11 Nov 2013 19:56 #11573

  • ewajoom
  • ewajoom's Avatar
  • Offline
  • Junior Member
  • Posts: 36
  • Thank you received: 2
  • Karma: 0
More precisions : I would like to have only activ tems (where table.activ=1), and the list orderer by my own order ( order by ordering)...
Anybody knows where is the sql request for combos lists ?

Thanks...
The administrator has disabled public write access.

ordering of combo 12 Nov 2013 11:44 #11575

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
In brief :

Solution A : Use the context state var.
In prepareQuery(), create a new context case, and call this context for your lists.

Lists are prepared in the view, so
1. find the model which prepare thoses items.
2. Just before getItems(), add
$model->setState('context', 'myContext');
3. Add your custom query in prepareQuery().
in the switch(), add a new case. Call it as your please.



Solution B :
Instance a regular filter directly in the view.

1. find the model which prepare thoses items. (same)
2. Just before getItems(), add
$model->setState('filter.ordering', 'a.activ = 1');

This is possible because ordering is already a possible filter.
If you want a special behaviour, so the use the solution A : Custom SQL Query.

In both cases A & B, the security ACL is always handled per default if you code it correctly.
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: ewajoom

ordering of combo 15 Nov 2013 05:59 #11613

  • ewajoom
  • ewajoom's Avatar
  • Offline
  • Junior Member
  • Posts: 36
  • Thank you received: 2
  • Karma: 0
Thanks for your clear explanations.
I think that it could be a good improvement in the builder.
The administrator has disabled public write access.
Time to create page: 0.068 seconds

Get Started