Welcome, Guest
Username: Password: Remember me

TOPIC: Reverse Ordering

Reverse Ordering 18 Sep 2012 11:14 #3732

  • semitone
  • semitone's Avatar
  • Offline
  • New Member
  • Posts: 5
  • Karma: 0
Hello,

I try to change the ordering of my default_grid_view list to reverse ordering.
I guess it would be better to do this in the Views or do i have to edit the model for this?

Sorry for such a noob-question, but any help will be apreciated.
The administrator has disabled public write access.

Re: Reverse Ordering 18 Sep 2012 12:34 #3733

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 414
  • Thank you received: 130
  • Karma: 46
It really depends
If you plan to use the same data but displayed in a different way order it at the view level
Something like model-> addorderby( 'ORDER BY a.whatever DESC' );

You may need to remove the
. orderby() in the respective function in the model

If you only plan to always display the data in the same order
Edit the model

Be aware that if you edit the orderby function in the model that it will cause all views to be displayed in that order

I would suggest to create another function in the model
And call it in the respective model function when needed
function OrderByDesc
{
'ORDER BY a.order DESC'
}

Sorry I don't have access to a downloaded project at the moment to provide the exact code but I hope it helps point you in the right direction
Last Edit: 18 Sep 2012 12:38 by BTB300.
The administrator has disabled public write access.
The following user(s) said Thank You: semitone

Re: Reverse Ordering 18 Sep 2012 13:45 #3738

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
In V2.0

Model -> prepareQuery()

All you need is in this function.
It contains the SQL for reading or enumerating the datas.
Almost all important SQL is there.

To my opinion, play with the states vars of the model.
Set up a state in the view. And read the state to change the behavior of the query.
Simple as that.
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: BTB300, semitone

Re: Reverse Ordering 18 Sep 2012 14:29 #3741

  • semitone
  • semitone's Avatar
  • Offline
  • New Member
  • Posts: 5
  • Karma: 0
Thanks a lot,

what i did was:

function _buildQueryOrderBy($order = array(), $pre_order = 'a.veranstaltungsbeginn DESC')

in the model

and it works :woohoo:
The administrator has disabled public write access.

Re: Reverse Ordering 23 Sep 2012 12:12 #3879

  • sonysony
  • sonysony's Avatar
  • Offline
  • New Member
  • Posts: 15
  • Thank you received: 5
  • Karma: 2
admin wrote:
In V2.0

Model -> prepareQuery()

All you need is in this function.
It contains the SQL for reading or enumerating the datas.
Almost all important SQL is there.

To my opinion, play with the states vars of the model.
Set up a state in the view. And read the state to change the behavior of the query.
Simple as that.

I was trying and playing around, but I cant figure out how this should work.
I need ordering for filters (order by ordering) and items in collection view (order by a.date)

Can anyone write me an example?
The administrator has disabled public write access.

Re: Reverse Ordering 23 Sep 2012 16:02 #3911

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
$model->setState('list.ordering', 'my_field');
$model->setState('list.direction', 'desc');
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: sonysony

Re: Reverse Ordering 23 Sep 2012 16:53 #3918

  • sonysony
  • sonysony's Avatar
  • Offline
  • New Member
  • Posts: 15
  • Thank you received: 5
  • Karma: 2
Damn I was so close, but I didnt get it to work.

Thank you!
The administrator has disabled public write access.
Time to create page: 0.093 seconds

Get Started