The plugin returns positive decimal values to negative

The plugin returns positive decimal values to negative

sephMsephM Posts: 4Questions: 0Answers: 0
edited October 2012 in Bug reports
I have a mysql table that has a column of positive decimal numbers. I test this with my select and even an echo via php. Its positive alright.

I setup a naked page with one column and did a setup of the plugin.


var dTable = $('#ranking').dataTable( {
"bProcessing": true,
"bServerSide": true,
"aaSorting": [[ 2, "desc" ]],
"aLengthMenu": [
[10, 25, 50, 100, -1],
[10, 25, 50, 100, 'All']
],
"iDisplayLength" : -1,
"sPaginationType": "full_numbers",
"sAjaxSource": "include/server_processing_manager.php"
} );
} );


the server_processing_php is

$aColumns = array( 'hourly_avg');

the rest is default. All files are included. Yet the column has negative decimal numbers

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Please link us to a page showing the problem.

    Allan
  • sephMsephM Posts: 4Questions: 0Answers: 0
    edited October 2012
    Okay thank you



    The column in question is hourly avg. I attempted to use these plugin to fix the problem but I am not getting anything different: http://datatables.net/plug-ins/sorting#numeric_comma
    http://datatables.net/plug-ins/type-detection

    I currently have a function manually fixing the column values. its being called as fixDecimals();

    function fixDecimals() {
    setTimeout(function() {
    $('table#ranking tbody tr').each(function() {
    var x = $(this).children('td:nth-child(5)').text();
    x = x.replace("-", "");
    $(this).children('td:nth-child(5)').text(x);
    });
    },2000);
    }

    But as you can see this is a temporary patch up at best.
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    So basically the problem is that the sorting is the wrong way around?

    DataTables is sending this to the server:

    > sSortDir_0:desc

    So it is the server's responsibility to sort it correctly. What is the SQL statement you are using?

    Allan
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    p.s. The sorting plug-ins will have no effect what so ever since the sorting is done at the server.

    Allan
  • sephMsephM Posts: 4Questions: 0Answers: 0
    edited October 2012
    No the sorting is fine. The numerical format comes out as a negative integer. The way it looks in my database is positive integer.

    TABLE

    COLUMN
    12.000
    32.000
    51.000

    the way it comes out on custom php code using $row = mysql_fetch_row($sql) is

    COLUMN
    12.000
    32.000
    51.000

    the way it comes out on datatables though is

    COLUMN
    -12.000
    -32.000
    -51.000
This discussion has been closed.