how to sort non-numeric input field

how to sort non-numeric input field

msand01msand01 Posts: 54Questions: 24Answers: 1
edited July 2015 in DataTables

I am following this example to add sorting on columns with an input field: http://datatables.net/examples/plug-ins/dom_sort.html

In my code below, the second targeted column (6), is a numeric field, and sorts fine, however the first column (5), a text column, doesn't sort at all. Using Chrome developer tools I can see it stepping into the function, but no sorting takes place. Both columns are input fields. I am using the latest DataTables version, 1.10.7.

   $.fn.dataTable.ext.order['dom-text'] = function  ( settings, col )
   {
      return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
         return $('input', td).val();
     } );
    }

    var table = $("#example").DataTable({
        "scrollY": "500px",
        "scrollX": "675px",
        "scrollCollapse": true,
        "paging": false,
        "order": [],
        "deferRender": true,
        "orderClasses": false,
        "columnDefs": [
            { "orderDataType": "dom-text", "targets": [5,6] }
        ]
    });

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin
    Answer ✓

    Can you link to a test case showing the issue please.

    Allan

  • msand01msand01 Posts: 54Questions: 24Answers: 1

    Hi Thank you very much for your reply - it is user error, I had left out the type: 'string' parameter in your example.

This discussion has been closed.