Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

ordering of combo 07 Nov 2013 15:21 #11547

  • ewajoom
  • ewajoom's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 36
  • Thank you received: 2
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!

Please Log in or Create an account to join the conversation.

ordering of combo 11 Nov 2013 19:56 #11573

  • ewajoom
  • ewajoom's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 36
  • Thank you received: 2
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...

Please Log in or Create an account to join the conversation.

ordering of combo 12 Nov 2013 11:44 #11575

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
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 following user(s) said Thank You: ewajoom

Please Log in or Create an account to join the conversation.

ordering of combo 15 Nov 2013 05:59 #11613

  • ewajoom
  • ewajoom's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 36
  • Thank you received: 2
Thanks for your clear explanations.
I think that it could be a good improvement in the builder.

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.054 seconds

Les générateurs de code je les connais presque tous pour les avoir essorés en long en large et en travers ... mais celui ci c'est vraiment un outil formidable de simplicité et d'efficacité !
Marc. (liubov - Forum)

Get Started