How can i sort date column in yadcf datatable?

How can i sort date column in yadcf datatable?

mrcheriemrcherie Posts: 2Questions: 1Answers: 0
edited November 2015 in Free community support

Hello, i have a problem. I hope you can help me.

I have a yadcf datatable which include date column. I can filter by date but i can not sort by date. Some of my codes is below.

<script>
$(document).ready(function(){
  $('#example').dataTable().yadcf([
        {column_number : 1, filter_type: "range_date", date_format: "dd.mm.yyyy", filter_default_label: ['ilk', 'son'], type: "date-eu"},
        {column_number : 2, filter_type: "date", date_format: "dd.mm.yyyy", filter_default_label: ['Tarih Seç']},
        {column_number : 3, filter_type: "auto_complete", filter_reset_button_text: ['Temizle']}
        ]);
});
</script>

and my tables code is below

<body id="yadcf_example">
    <div id="container">

  <table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
            <thead>
              <tr>
                <th>Order Date</th>
                <th>Out Date</th>
                <th>Customer</th>
              </tr>
            </thead>
            <tbody>
            
            <tr class="odd gradeX">
                  <td>01.10.2015</td>
                  <td>05.10.2015</td>
                  <td>John</td>
                </tr>
            <tr class="odd gradeX">
                  <td>02.11.2015</td>
                  <td>05.11.2015</td>
                  <td>David</td>
                </tr>
            <tr class="odd gradeX">
                  <td>30.01.2015</td>
                  <td>15.02.2015</td>
                  <td>Sue</td>
                </tr>
            <tr class="odd gradeX">
                  <td>09.12.2015</td>
                  <td>15.12.2015</td>
                  <td>Mark</td>
                </tr>

        </tbody>
          </table>
    </div>
  </body>

Answers

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75
    edited November 2015

    What I would suggest, is using the html5_data option, then add a data-search="" option with the EPOCH date as the value, then that would have DataTables and YADCF

    From the yadcf .js file comments:

    Possible values: data-filter / data-search / anything that is supported by datatables

    Description: Allows to filter based on data-filter / data-search attributes of the <td> element, read more: http://www.datatables.net/examples/advanced_init/html5-data-attributes.html

    Im pretty sure the data-filter handles the sorting as well. But @daniel_r would be able to answer that for sure

  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67

    I think he got his answer on github already

  • mrcheriemrcherie Posts: 2Questions: 1Answers: 0

    yes, got it, thanks

This discussion has been closed.