⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

order by date



kris

kris
  • profile picture
  • Member

Posted 17 June 2017 - 19:11 PM

When I clic on title of the column, the order is not ordered by date but it is like text ordered.

 

I have 01.01.2005 then 01.01.2006 then 01.01.2007 etc... I should have 01.01.2005 then 02.01.2005 etcl  How to order by date

 

Additionaly I want the default order by date desc the newst date at the top

 


xheradon

xheradon
  • profile picture
  • Member

Posted 19 June 2017 - 06:37 AM

$crud->order_by('date','desc');

 

https://www.grocerycrud.com/documentation/options_functions/order_by


kris

kris
  • profile picture
  • Member

Posted 19 June 2017 - 21:22 PM

But how to display a date in iso format because in european format the order is not nice when I click on header of the colomn.

 

I will do that for my default order by

$crud->order_by('date','desc');


xheradon

xheradon
  • profile picture
  • Member

Posted 20 June 2017 - 06:35 AM

If you need to manipulate data before display, you can use column callback.

 

https://www.grocerycrud.com/documentation/options_functions/callback_column


kris

kris
  • profile picture
  • Member

Posted 20 June 2017 - 17:13 PM

When I want to display a date in iso format I don't do anythng juste date("Y-m-d"); But with GC simple thing is hard.

 

 

 

I found

 

    $crud->callback_column('tldate',array($this,'_dateiso'));

 

...

 

public function _dateiso($value, $row)
{
return $row->tldate;
}

 

 

It works next step will be to have date > or < from a date but the priority is it find a correct theme because datatable is not optimised. I read all records during long seconds then it display only 10 records. Why not reading 10 records only ???  _How will you do with table with millions of records