sorting plugin configuration anti-the
sorting plugin configuration anti-the
I'm having a hard time getting the anti-the sorting plugin to work for me. (Actually it will work if I have an empty configuration, but with the sDom being used I can't get it to work.)
Thanks, I appreciate all help.
[code]
jQuery.fn.dataTableExt.oSort['anti-the-asc'] = function(a,b) {
var x = a.replace(/^the /i, "");
var y = b.replace(/^the /i, "");
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};
jQuery.fn.dataTableExt.oSort['anti-the-desc'] = function(a,b) {
var x = a.replace(/^the /i, "");
var y = b.replace(/^the /i, "");
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};
$(document).ready(function() {
/* Initialise datatables */
var oTable = $('#courseindex').dataTable({
"bPaginate": false,
"bAutoWidth": false,
"bStateSave": true,
"oLanguage": { "sSearch": "Filter:" },
"sDom": '<"top"f><"showing"i>rt',
"aoColumns": [
{ "sType": [ "anti-the-asc", "anti-the-desc" ] },
null,
null,
null,
{ "sType": "numeric" },
null,
null,
{ "asSorting": [ "desc", "asc" ] },
{ "asSorting": [ "desc", "asc" ] },
{ "asSorting": [ "desc", "asc" ] },
{ "asSorting": [ "desc", "asc" ] },
null,
null,
null,
null,
null
]
});
$("#advanced_search").appendTo("#courseindex_wrapper .top");
$("#advanced_search").removeClass("hidden");
/* Add event listeners */
$('select#filterday').change( function() { oTable.fnFilter( $(this).val(), 14 ); } );
$('select#filtercredits').change( function() { oTable.fnFilter( $(this).val(), 5 ); } );
$('select#filterstanding').change( function() { oTable.fnFilter( $(this).val(), 15 ); } );
$('select#filteroffered').change( function() { oTable.fnFilter( $(this).val(), 6 ); } );
$("#theSelect").change(function(){
var value = $("#theSelect option:selected").val();
if (value === '') return;
var theDiv = $(".is" + value);
theDiv.fadeIn().removeClass("hidden");
$("#theSelect option:selected").attr('disabled','disabled');
$(this).val('');
});
$("div a.remove").click(function () {
var value = $(this).attr('rel');
var theDiv = $(".is" + value);
var colid = $(this).parent().attr('rel');
oTable.fnFilter( "", colid );
$("#theSelect option[value=" + value + "]").removeAttr('disabled');
$(this).parent().fadeOut(function() { $(this).addClass("hidden"); });
});
} );
[/code]
Thanks, I appreciate all help.
[code]
jQuery.fn.dataTableExt.oSort['anti-the-asc'] = function(a,b) {
var x = a.replace(/^the /i, "");
var y = b.replace(/^the /i, "");
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};
jQuery.fn.dataTableExt.oSort['anti-the-desc'] = function(a,b) {
var x = a.replace(/^the /i, "");
var y = b.replace(/^the /i, "");
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};
$(document).ready(function() {
/* Initialise datatables */
var oTable = $('#courseindex').dataTable({
"bPaginate": false,
"bAutoWidth": false,
"bStateSave": true,
"oLanguage": { "sSearch": "Filter:" },
"sDom": '<"top"f><"showing"i>rt',
"aoColumns": [
{ "sType": [ "anti-the-asc", "anti-the-desc" ] },
null,
null,
null,
{ "sType": "numeric" },
null,
null,
{ "asSorting": [ "desc", "asc" ] },
{ "asSorting": [ "desc", "asc" ] },
{ "asSorting": [ "desc", "asc" ] },
{ "asSorting": [ "desc", "asc" ] },
null,
null,
null,
null,
null
]
});
$("#advanced_search").appendTo("#courseindex_wrapper .top");
$("#advanced_search").removeClass("hidden");
/* Add event listeners */
$('select#filterday').change( function() { oTable.fnFilter( $(this).val(), 14 ); } );
$('select#filtercredits').change( function() { oTable.fnFilter( $(this).val(), 5 ); } );
$('select#filterstanding').change( function() { oTable.fnFilter( $(this).val(), 15 ); } );
$('select#filteroffered').change( function() { oTable.fnFilter( $(this).val(), 6 ); } );
$("#theSelect").change(function(){
var value = $("#theSelect option:selected").val();
if (value === '') return;
var theDiv = $(".is" + value);
theDiv.fadeIn().removeClass("hidden");
$("#theSelect option:selected").attr('disabled','disabled');
$(this).val('');
});
$("div a.remove").click(function () {
var value = $(this).attr('rel');
var theDiv = $(".is" + value);
var colid = $(this).parent().attr('rel');
oTable.fnFilter( "", colid );
$("#theSelect option[value=" + value + "]").removeAttr('disabled');
$(this).parent().fadeOut(function() { $(this).addClass("hidden"); });
});
} );
[/code]
This discussion has been closed.
Replies
Regards,
Allan
[code]
var oTable = $('#courseindex').dataTable({
"bPaginate": false,
"bAutoWidth": false,
"bStateSave": true,
"oLanguage": { "sSearch": "Filter:" },
"sDom": '<"top"f><"showing"i>rt',
"aoColumns": [
{ "sType": "anti-the" },
null,
null,
null,
{ "sType": "numeric" },
null,
null,
{ "asSorting": [ "desc", "asc" ] },
{ "asSorting": [ "desc", "asc" ] },
{ "asSorting": [ "desc", "asc" ] },
{ "asSorting": [ "desc", "asc" ] },
null,
null,
null,
null,
null
]
});
[/code]
[code]
var oTable = $('#courseindex').dataTable({
"bPaginate": false,
"bAutoWidth": false,
"bStateSave": true,
"oLanguage": { "sSearch": "Filter:" },
"sDom": '<"top"f><"showing"i>rt',
"aaSorting": [],
"aoColumns": [
null,
null,
null,
null,
{ "sType": "numeric" },
null,
null,
{ "asSorting": [ "desc", "asc" ] },
{ "asSorting": [ "desc", "asc" ] },
{ "asSorting": [ "desc", "asc" ] },
{ "asSorting": [ "desc", "asc" ] },
null,
null,
null,
null,
null
]
});
[/code]