Welcome, Guest
Username: Password: Remember me

TOPIC: [SOLVED] Sortable by id

[SOLVED] Sortable by id 08 Oct 2011 17:57 #167

  • Kevin
  • Kevin's Avatar
I see that cook automatically adds the id field in the table.

When in collection layout I cannot sort the items by the id.

Is there an option available.
Last Edit: 11 Oct 2011 13:46 by admin.
The administrator has disabled public write access.

Re: Sortable by id 10 Oct 2011 14:45 #178

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
The table is ordered by default on it's default field.

You can do this putting an ID column in the grid, and sort on it.
To instance the ID key of the table, just drag-drop the root of the fields tree.

OR

In your view, simply add :
$model->addOrder("a.id");

OR

In the model, change the default ordering key ('pre_order', or something like this, if I remember)




That's all.
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: Kevin

Re: Sortable by id 10 Oct 2011 16:13 #182

  • Kevin
  • Kevin's Avatar
Excellent..... Got my id field now.

Thanks
The administrator has disabled public write access.
Time to create page: 0.071 seconds

Get Started