order column by date

order column by date

mdesignmdesign Posts: 72Questions: 17Answers: 0

within my columns function i render my mysql date to readable german version, like

31/08/2017<br>
23:10

how can i ensure the correct sorting by clicking the column head now ?

    var thisDataTable = $('table.editorTable').DataTable({
      ajax:  { 
        url:  '-admin/editor-alle_post-ssp.php', 
        type: 'POST',
      },

      order:       [[1, 'desc' ]], /* default (idn) wenn nicht stateSave */
      pageLength:  50,
      stateSave:   true,
      colReorder:  true,
  
      columns: [

            // Datum von
        { data: null,
          className: '-text-right',
          render: function (data, type, row) {
            var output = data.alle_post.post_dup.replace(' - ', '<br>'); /* Zeilenumbruch vor Uhrzeit */
              if(data.alle_post.post_dup.includes('0001')) { output = ''; }
                return output;
          },
          editField: 'alle_post.post_dup',
        },

    }); // thisDataTable

Answers

  • kthorngrenkthorngren Posts: 20,309Questions: 26Answers: 4,770

    Use the solution provided in this blog about sorting dates.

    Kevin

  • mdesignmdesign Posts: 72Questions: 17Answers: 0

    thx. before i check your link. can we do the sorting in editor ajax tables like in normal datatables like
    <td data-order="123">

    this would be much easier.

  • kthorngrenkthorngren Posts: 20,309Questions: 26Answers: 4,770

    You can use HTML 5 data attributes as described here and shown in this example.

    Just to clarify....

    The Editor doesn't show or sort any of the client data. That is performed by Datatables. The Editor is an added code that allow for editing the data.

    Kevin

This discussion has been closed.