[sorting] null values first
[sorting] null values first
Dear all!
Is it possible to have datatables sort columns with null values (empty cells) frist? If I sort values in a descending order, null values will be the last on e(which is intuitive, but not what I want).
In SQL, you can do it like this:
[code]
SELECT * FROM table
ORDER BY ISNULL(column_with_some_null_values) DESC, column_with_some_null_values DESC
[/code]
Here is a small example of how it is now (null values last):
[code]
DataTables example - Grouped Columns with server side
@import "lib/DataTables-1.7.5/media/css/demo_page.css";
@import "lib/DataTables-1.7.5/media/css/demo_table.css";
var iGroupingColumn = 2;
$(document).ready(function() {
$('#example').dataTable( {
"fnDrawCallback": function ( oSettings ) {
if ( oSettings.aiDisplay.length == 0 )
{
return;
}
var nTrs = $('#example tbody tr');
var iColspan = nTrs[0].getElementsByTagName('td').length;
var sLastGroup = "";
for ( var i=0 ; i
Is it possible to have datatables sort columns with null values (empty cells) frist? If I sort values in a descending order, null values will be the last on e(which is intuitive, but not what I want).
In SQL, you can do it like this:
[code]
SELECT * FROM table
ORDER BY ISNULL(column_with_some_null_values) DESC, column_with_some_null_values DESC
[/code]
Here is a small example of how it is now (null values last):
[code]
DataTables example - Grouped Columns with server side
@import "lib/DataTables-1.7.5/media/css/demo_page.css";
@import "lib/DataTables-1.7.5/media/css/demo_table.css";
var iGroupingColumn = 2;
$(document).ready(function() {
$('#example').dataTable( {
"fnDrawCallback": function ( oSettings ) {
if ( oSettings.aiDisplay.length == 0 )
{
return;
}
var nTrs = $('#example tbody tr');
var iColspan = nTrs[0].getElementsByTagName('td').length;
var sLastGroup = "";
for ( var i=0 ; i
This discussion has been closed.