Welcome, Guest
Username: Password: Remember me

TOPIC: Ordering of Grids and Select boxes.. going insane

Ordering of Grids and Select boxes.. going insane 09 Jul 2014 13:33 #12511

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 15
Grids

I have tried altering the piece of code directly in the VIEW i.e
$model		= $this->model;
$user		= JFactory::getUser();
$userId		= $user->get('id');

$model->setState('list.ordering', 'a.creation_date');
$model->setState('list.direction', 'desc');

$listOrder	= $this->escape($this->state->get('list.ordering'));
$listDirn	= $this->escape($this->state->get('list.direction'));
$saveOrder	= $listOrder == 'a.ordering' && $listDirn != 'desc';

I have also tried changing the $saveOrder to
$saveOrder	= $listOrder == 'a.creation_date' && $listDirn != 'desc';

Nothing works... I cant make the grids change order. PLease can anyone advise how they have changed the default ordering of their grids :blink:


Also, more of an aside, why do select lists, by default, show all records including unpublished ones. Surely it would be a better default not to show anything in the select list other than a.published=1
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla
The administrator has disabled public write access.

Ordering of Grids and Select boxes.. going insane 16 Jul 2014 11:09 #12512

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
In the buillder, set the field "creation_date" as default (starred) in your table definition.
The field should be sortable in the Backend collection view
The administrator has disabled public write access.

Ordering of Grids and Select boxes.. going insane 26 Jul 2014 11:39 #12543

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
If you are using grid groups, then it may be the prioritary order that makes the confusion.

You can try directly :
$model->addOrder('a.creation_date');

or
$model->addGroupOrder('a.creation_date');

Also you can check the default ordering in the populateState() function of the model.
The default ordering is defined at the end of the function, when it calls the parent::populateState('a.xxxxx','desc')

Hope it helps.

About the unpublished items in the lists... it depends. Sometimes it is usefull in order to no break the link if you edit an item referring to unpublished item. It is easy to achieve this function you ask.

In the view, the FK list is loaded.
Just add :
$model->addWhere('a.published', '1');

or with state vars:
$model->setState('filter.published', true);

Thats it.
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.056 seconds

Get Started