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

TOPIC:

Reverse Ordering 18 Sep 2012 11:14 #3732

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.

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

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

  • BTB300
  • BTB300's Avatar
  • Away
  • Moderator
  • Moderator
  • Posts: 415
  • Thank you received: 132
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
The following user(s) said Thank You: semitone

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

Last edit: by BTB300.

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

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

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

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

Thanks a lot,

what i did was:

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

in the model

and it works :woohoo:

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

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

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?

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

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
$model->setState('list.ordering', 'my_field');
$model->setState('list.direction', 'desc');
Coding is now a piece of cake
The following user(s) said Thank You: sonysony

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

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

Damn I was so close, but I didnt get it to work.

Thank you!

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

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

Awards for the best Joomla app. This product is gonna win an award for this amazing job. Cook Self Service is the the best application from all over the Joomla universe ! It brings Joomla to a professional level really advanced for developers. It is a real fun to develop with it. The ACL part and security checks implementation are just... so much hours saved. I can now concentrate myself more on the design part and the creative works. Thank you so much. Guys I offer you all my congratulation ! Keep up the works because Joomla is needing it to increase the quality of extensions availables on the JED. I also learned a lot because I can see how to code at the proper place and I found all my answers reading the forum.
lack_hanson (JED)
          

Get Started