Sorting Form Not Working - Debug code: ecinan

Sorting Form Not Working - Debug code: ecinan

RemyHouardRemyHouard Posts: 7Questions: 0Answers: 0
edited April 2013 in DataTables 1.9
Hello,

I downloaded DataTables recently and i'm having some issues with sorting form fields. In this case a checkbox.
There is an example here with 2 forms one working (without input sorting) and another not working:
http://sistema.chezremy.com.br/?site=mm&do=playground&udo=data-tables

Debug code: ecinan

Thak you for you time and Great Job!

Replies

  • RemyHouardRemyHouard Posts: 7Questions: 0Answers: 0
    UPDATE.

    I got it working halfway. New Code: uqehik
    Same link.

    Now the table loads and I get no error on the console.
    However the sorting is broken.

    Once again thank you.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    If you want to sort live DOM elements, you need to use plug-ins like those shown here: http://datatables.net/release-datatables/examples/plug-ins/dom_sort.html

    Allan
  • RemyHouardRemyHouard Posts: 7Questions: 0Answers: 0
    Hello Allan

    I apreciate the swift reply.

    I have used the code in your link example. In fact my second table is pretty much a copy-paste of it.

    DataTables loads and tries to sort the checkbox. It does work halfway, the rows are re-ordered but the sort is broken.

    I have removed the first table of my example page. I see now that it was redundant.
    New code: ugenug

    Remy
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Try using this function instead:

    [code]
    $.fn.dataTableExt.afnSortData['dom-checkbox'] = function ( oSettings, iColumn )
    {
    return $.map( oSettings.oApi._fnGetTrNodes(oSettings), function (tr, i) {
    return $('td:eq('+iColumn+') input', tr).prop('checked') ? '1' : '0';
    } );
    }
    [/code]

    jQuery 1.9 changed how nodes which are not in the document are ordered with broke the old method. The up-to-date methods are found on the page I linked to.

    Allan
  • RemyHouardRemyHouard Posts: 7Questions: 0Answers: 0
    Works like a charm.
    Thank you!

    Is there a browser compatibility issue I should know about?
This discussion has been closed.