Not logged in - Login

jQuery Datatables


/*JQUERY DATATABLES */
/* Add class to the columns you do not wish to sort */

        $("#tablepress-12 thead tr th.column-1").addClass("no-sort");
        $("#tablepress-12 thead tr th.column-2").addClass("no-sort");
        $("#tablepress-12 thead tr th.column-8").addClass("no-sort");

      /* EXTENSIONS */
     /* formatted numbers extension */

        jQuery.extend( jQuery.fn.dataTableExt.oSort, {
            "formatted-num-pre": function ( a ) {
                a = (a === "-" || a === "") ? 0 : a.replace( /[^\d\-\.]/g, "" );
                return parseFloat( a );
            },

            "formatted-num-asc": function ( a, b ) {
                return a - b;
            },

            "formatted-num-desc": function ( a, b ) {
                return b - a;
            }
        } );


      /* currency extension */

        jQuery.extend( jQuery.fn.dataTableExt.oSort, {
            "currency-pre": function ( a ) {
                a = (a==="-") ? 0 : a.replace( /[^\d\-\.]/g, "" );
                return parseFloat( a );
            },

            "currency-asc": function ( a, b ) {
                return a - b;
            },

            "currency-desc": function ( a, b ) {
                return b - a;
            }
        } );

       /* Plugin call */
        /* Each one in aoColumns represents a column */
        $('.data-table-sort').dataTable({
            "aoColumns": [
                null,
                null,
                null,
                { "sType": "formatted-num" },
                null,
                null,
                null,
                null
            ],"aoColumnDefs": [
                { 'bSortable': false, 'aTargets': ["no-sort" ] }
            ]
        });