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

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.067 seconds

I've evaluated lots of other Joomla Component Dev tools such as Shell Manager (J)enesis Danny's Joomla! 1.5 MVC Component Code Generator Marco's Component Maker and I must admit that I love what I see on your site! Lots of potential... Otherwise Great Job and keep up the good work!!!
Clifton (forum)

Get Started