The plugin returns positive decimal values to negative
The plugin returns positive decimal values to negative
sephM
Posts: 4Questions: 0Answers: 0
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
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
This discussion has been closed.
Replies
Allan
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.
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
Allan
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