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

TOPIC:

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

  • MorganL
  • MorganL's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
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

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

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

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

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

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
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

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

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

  I found "cook" two days ago. Played around with it for a day and then within a day got rid of two legacy applications in IBM Lotus Domino Notes and replaced them with "cook". It was really easy. A piece of cake. Actually it was even easier than cooking. Cooking involves more work than developing with "cook". What can I say about "cook"? Great application great price for what it delivers great forum with a lot of information and fast responses active and friendly community fast forward moving development cycle So what should I say "Monsieur Le Cook"? Keep the good work going it will lead to success. Having become a paying member in the words of Edith Piaf may I say ..... non rien de rien ... je ne regrette rien. Vive La France.
FK (JED)
         

Get Started