Commit 8b7ee7dd authored by Daniel Brown's avatar Daniel Brown
Browse files

adding proper numerical sorting to tables

parent b17ee590
......@@ -34,9 +34,31 @@
<script type="text/JavaScript">
$(document).ready(function(){
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"num-html-pre": function ( a ) {
var x = String(a).replace( /<[\s\S]*?>/g, "" );
return parseFloat( x );
},
"num-html-asc": function ( a, b ) {
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
},
"num-html-desc": function ( a, b ) {
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
}
} );
gtable = $('#tblHistory').dataTable();
gtable = $('#tblHistory').dataTable({
"iDisplayLength":250,
"aoColumns": [
{ "sType": "num-html" },
null,
{ "sType": "date" },
{ "sType": "numeric" },
{ "sType": "numeric" }
]
} );
});
</script>
......
......@@ -52,9 +52,40 @@
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>
<script type="text/JavaScript">
$(document).ready(function(){
gtable = $('#tblResults').dataTable();
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"num-html-pre": function ( a ) {
console.log("1");
var x = String(a).replace( /<[\s\S]*?>/g, "" );
return parseFloat( x );
},
"num-html-asc": function ( a, b ) {
console.log("2");
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
},
"num-html-desc": function ( a, b ) {
console.log("3");
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
}
} );
gtable = $('#tblResults').dataTable({
"iDisplayLength":250,
"aLengthMenu": [[-1], ['All']],
"aoColumns": [
null,
null,
{ "sType": "numeric" },
{"bSearchable": false, "bSortable": false},
{"bSearchable": false, "bSortable": false},
{"bSearchable": false, "bSortable": false},
{"bSearchable": false, "bSortable": false},
{"bSearchable": false, "bSortable": false}
]
} );
});
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment