sorting plugin configuration anti-the

sorting plugin configuration anti-the

jeffreyjeffrey Posts: 16Questions: 0Answers: 0
edited September 2010 in Plug-ins
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]

Replies

  • allanallan Posts: 55,815Questions: 1Answers: 8,815 Site admin
    sType is just a string, not an array. Try sType: "anti-the" for the aoColumns entry.

    Regards,
    Allan
  • jeffreyjeffrey Posts: 16Questions: 0Answers: 0
    Didn't work either. Below is what I changed.

    [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]
  • jeffreyjeffrey Posts: 16Questions: 0Answers: 0
    If I change the following it will work listing the titles alphabetical and skipping the "The"s... but when it is sorted on, it goes back to including The.

    [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]
This discussion has been closed.