KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Datatables - sorting by date #1307

Closed Jeno Haraszti opened this topic on on Feb 19, 2020 - 3 comments

Jeno Haraszti commented on Feb 19, 2020


I have a datatable with the following definition:

  				"format"=>"Y-m-d H:i:s",
 				"displayFormat"=>"m/d/Y G:iA"

On display, when I click for sorting, it sorts incorrectly, like this.

The date of 09/12/2019 should be at the top.

Can you please help me in solving this?

Thanks in advance!

David Winterburn commented on Feb 24, 2020

Hi Jeno,

datagrid/DataTables widget has a column options' property called data-order that allows a column to be sorted by another column's value. So in your case I would clone your record_date and sort record_date by the cloned column like this:

    ->pipe(new \koolreport\processes\CopyColumn([
      "record_date_2" => "record_date"

                        "record_date" => [
                            "format"=>"Y-m-d H:i:s",
                            "displayFormat"=>"m/d/Y G:iA" ,
                            "data-order" => "record_date_2",                     

Let me know how this works for you. Thanks!

Jeno Haraszti commented on Feb 24, 2020

Hi, David!

Thanks for the hint. I will try it and let you know.


Jeno Haraszti commented on Feb 25, 2020

Tested OK :-) Thank you, it works great! Regards, Jenő

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed