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

Just wanted to congratulate you on the J-Cook website / web development tool. In a couple of visits I've had a play around with Cook and have to say I think it is fantastic.  I've played with a number of component builders in the past and yours is certainly looking like the best so far. I'd also like to help you spread the word - I'm really surprised more people aren't excited about this tool. Good luck with the project.
Dean

Get Started