diff --git a/pagination/bootstrap.js b/pagination/bootstrap.js new file mode 100644 index 0000000..dbaf34f --- /dev/null +++ b/pagination/bootstrap.js @@ -0,0 +1,106 @@ +/** + * This plug-in provides the mark-up needed for using Twitter Bootstrap's + * pagination styling with DataTables. Note that this plug-in uses the + * fnPagingInfo API plug-in method to obtain paging information. + * @name Twitter Bootstrap + * @author Allan Jardine + * + * @example + * $(document).ready(function() { + * $('#example').dataTable( { + * "sPaginationType": "bootstrap" + * } ); + * } ); + */ + + +/* API method to get paging information */ +$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings ) +{ + return { + "iStart": oSettings._iDisplayStart, + "iEnd": oSettings.fnDisplayEnd(), + "iLength": oSettings._iDisplayLength, + "iTotal": oSettings.fnRecordsTotal(), + "iFilteredTotal": oSettings.fnRecordsDisplay(), + "iPage": Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ), + "iTotalPages": Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength ) + }; +} + +/* Bootstrap style pagination control */ +$.extend( $.fn.dataTableExt.oPagination, { + "bootstrap": { + "fnInit": function( oSettings, nPaging, fnDraw ) { + var oLang = oSettings.oLanguage.oPaginate; + var fnClickHandler = function ( e ) { + e.preventDefault(); + if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) { + fnDraw( oSettings ); + } + }; + + $(nPaging).addClass('pagination').append( + '' + ); + var els = $('a', nPaging); + $(els[0]).bind( 'click.DT', { action: "previous" }, fnClickHandler ); + $(els[1]).bind( 'click.DT', { action: "next" }, fnClickHandler ); + }, + + "fnUpdate": function ( oSettings, fnDraw ) { + var iListLength = 5; + var oPaging = oSettings.oInstance.fnPagingInfo(); + var an = oSettings.aanFeatures.p; + var i, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2); + + if ( oPaging.iTotalPages < iListLength) { + iStart = 1; + iEnd = oPaging.iTotalPages; + } + else if ( oPaging.iPage <= iHalf ) { + iStart = 1; + iEnd = iListLength; + } else if ( oPaging.iPage >= (oPaging.iTotalPages-iHalf) ) { + iStart = oPaging.iTotalPages - iListLength + 1; + iEnd = oPaging.iTotalPages; + } else { + iStart = oPaging.iPage - iHalf + 1; + iEnd = iStart + iListLength - 1; + } + + for ( i=0, iLen=an.length ; i'+j+'') + .insertBefore( $('li:last', an[i])[0] ) + .bind('click', function (e) { + e.preventDefault(); + oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength; + fnDraw( oSettings ); + } ); + } + + // Add / remove disabled classes from the static elements + if ( oPaging.iPage === 0 ) { + $('li:first', an[i]).addClass('disabled'); + } else { + $('li:first', an[i]).removeClass('disabled'); + } + + if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) { + $('li:last', an[i]).addClass('disabled'); + } else { + $('li:last', an[i]).removeClass('disabled'); + } + } + } + } +} ); diff --git a/pagination/extjs.js b/pagination/extjs.js new file mode 100644 index 0000000..79c7323 --- /dev/null +++ b/pagination/extjs.js @@ -0,0 +1,104 @@ +/** + * This pagination plug-in provides pagination controls for DataTables which + * match the style and interaction of the ExtJS library's grid component. + * @name ExtJS style + * @author Zach Curtis + * + * @example + * $(document).ready(function() { + * $('#example').dataTable( { + * "sPaginationType": "extStyle" + * } ); + * } ); + */ + +$.fn.dataTableExt.oPagination.extStyle = { + "fnInit": function (oSettings, nPaging, fnCallbackDraw) { + nFirst = $('', { 'class': 'paginate_button first' }); + nPrevious = $('', { 'class': 'paginate_button previous' }); + nNext = $('', { 'class': 'paginate_button next' }); + nLast = $('', { 'class': 'paginate_button last' }); + nPageTxt = $("", { text: 'Page' }); + nPageNumBox = $('', { type: 'text', val: 1, 'class': 'pageinate_input_box' }); + nPageOf = $('', { text: 'of' }); + nTotalPages = $('', { text: parseInt(oSettings.aoData.length / oSettings._iDisplayLength, 10) }); + + $(nPaging) + .append(nFirst) + .append(nPrevious) + .append(nPageTxt) + .append(nPageNumBox) + .append(nPageOf) + .append(nTotalPages) + .append(nNext) + .append(nLast); + + nFirst.click(function () { + oSettings.oApi._fnPageChange(oSettings, "first"); + fnCallbackDraw(oSettings); + nPageNumBox.val(parseInt(oSettings._iDisplayEnd / oSettings._iDisplayLength, 10)); + }).bind('selectstart', function () { return false; }); + + nPrevious.click(function () { + oSettings.oApi._fnPageChange(oSettings, "previous"); + fnCallbackDraw(oSettings); + nPageNumBox.val(parseInt(oSettings._iDisplayEnd / oSettings._iDisplayLength, 10)); + }).bind('selectstart', function () { return false; }); + + nNext.click(function () { + oSettings.oApi._fnPageChange(oSettings, "next"); + fnCallbackDraw(oSettings); + nPageNumBox.val(parseInt(oSettings._iDisplayEnd / oSettings._iDisplayLength, 10)); + }).bind('selectstart', function () { return false; }); + + nLast.click(function () { + oSettings.oApi._fnPageChange(oSettings, "last"); + fnCallbackDraw(oSettings); + nPageNumBox.val(parseInt(oSettings._iDisplayEnd / oSettings._iDisplayLength,10 )); + }).bind('selectstart', function () { return false; }); + + nPageNumBox.focus(function () { + $(this).attr("style", "border-color: #D0B39A"); + }).blur(function () { + $(this).attr("style", "border-color: #C9C9C9"); + }).change(function () { + var pageValue = parseInt($(this).val(), 10); + if ((pageValue !== NaN) && pageValue > 0 && pageValue < oSettings.aoData.length) { + oSettings._iDisplayStart = $(this).val(); + fnCallbackDraw(oSettings); + } + }); + + }, + + + "fnUpdate": function (oSettings, fnCallbackDraw) { + if (!oSettings.aanFeatures.p) { + return; + } + + /* Loop over each instance of the pager */ + var an = oSettings.aanFeatures.p; + for (var i = 0, iLen = an.length; i < iLen; i++) { + //var buttons = an[i].getElementsByTagName('span'); + var buttons = $(an[i]).find('span.paginate_button'); + if (oSettings._iDisplayStart === 0) { + buttons.eq(0).attr("class", "paginate_disabled_first paginate_button"); + buttons.eq(1).attr("class", "paginate_disabled_previous paginate_button"); + } + else { + buttons.eq(0).attr("class", "paginate_enabled_first paginate_button"); + buttons.eq(1).attr("class", "paginate_enabled_previous paginate_button"); + } + + if (oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay()) { + buttons.eq(2).attr("class", "paginate_disabled_next paginate_button"); + buttons.eq(3).attr("class", "paginate_disabled_last paginate_button"); + } + else { + buttons.eq(2).attr("class", "paginate_enabled_next paginate_button"); + buttons.eq(3).attr("class", "paginate_enabled_last paginate_button"); + } + } + } +}; diff --git a/pagination/four_button.js b/pagination/four_button.js new file mode 100644 index 0000000..9f0cd0e --- /dev/null +++ b/pagination/four_button.js @@ -0,0 +1,102 @@ +/** + * The built-in pagination functions provide either two buttons (forward / back) + * or lots of buttons (forward, back, first, last and individual pages). This + * plug-in meets the two in the middle providing navigation controls for forward, back, first and last. + * @name Four button navigation + * @author Allan Jardine + * + * @example + * $(document).ready(function() { + * $('#example').dataTable( { + * "sPaginationType": "four_button" + * } ); + * } ); + */ + +$.fn.dataTableExt.oPagination.four_button = { + "fnInit": function ( oSettings, nPaging, fnCallbackDraw ) + { + nFirst = document.createElement( 'span' ); + nPrevious = document.createElement( 'span' ); + nNext = document.createElement( 'span' ); + nLast = document.createElement( 'span' ); + + nFirst.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sFirst ) ); + nPrevious.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sPrevious ) ); + nNext.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sNext ) ); + nLast.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sLast ) ); + + nFirst.className = "paginate_button first"; + nPrevious.className = "paginate_button previous"; + nNext.className="paginate_button next"; + nLast.className = "paginate_button last"; + + nPaging.appendChild( nFirst ); + nPaging.appendChild( nPrevious ); + nPaging.appendChild( nNext ); + nPaging.appendChild( nLast ); + + $(nFirst).click( function () { + oSettings.oApi._fnPageChange( oSettings, "first" ); + fnCallbackDraw( oSettings ); + } ); + + $(nPrevious).click( function() { + oSettings.oApi._fnPageChange( oSettings, "previous" ); + fnCallbackDraw( oSettings ); + } ); + + $(nNext).click( function() { + oSettings.oApi._fnPageChange( oSettings, "next" ); + fnCallbackDraw( oSettings ); + } ); + + $(nLast).click( function() { + oSettings.oApi._fnPageChange( oSettings, "last" ); + fnCallbackDraw( oSettings ); + } ); + + /* Disallow text selection */ + $(nFirst).bind( 'selectstart', function () { return false; } ); + $(nPrevious).bind( 'selectstart', function () { return false; } ); + $(nNext).bind( 'selectstart', function () { return false; } ); + $(nLast).bind( 'selectstart', function () { return false; } ); + }, + + + "fnUpdate": function ( oSettings, fnCallbackDraw ) + { + if ( !oSettings.aanFeatures.p ) + { + return; + } + + /* Loop over each instance of the pager */ + var an = oSettings.aanFeatures.p; + for ( var i=0, iLen=an.length ; iAllan Jardine + * + * @example + * $(document).ready(function() { + * $('#example').dataTable( { + * "sPaginationType": "input" + * } ); + * } ); + */ + +$.fn.dataTableExt.oPagination.input = { + "fnInit": function ( oSettings, nPaging, fnCallbackDraw ) + { + var nFirst = document.createElement( 'span' ); + var nPrevious = document.createElement( 'span' ); + var nNext = document.createElement( 'span' ); + var nLast = document.createElement( 'span' ); + var nInput = document.createElement( 'input' ); + var nPage = document.createElement( 'span' ); + var nOf = document.createElement( 'span' ); + + nFirst.innerHTML = oSettings.oLanguage.oPaginate.sFirst; + nPrevious.innerHTML = oSettings.oLanguage.oPaginate.sPrevious; + nNext.innerHTML = oSettings.oLanguage.oPaginate.sNext; + nLast.innerHTML = oSettings.oLanguage.oPaginate.sLast; + + nFirst.className = "paginate_button first"; + nPrevious.className = "paginate_button previous"; + nNext.className="paginate_button next"; + nLast.className = "paginate_button last"; + nOf.className = "paginate_of"; + nPage.className = "paginate_page"; + + if ( oSettings.sTableId !== '' ) + { + nPaging.setAttribute( 'id', oSettings.sTableId+'_paginate' ); + nPrevious.setAttribute( 'id', oSettings.sTableId+'_previous' ); + nPrevious.setAttribute( 'id', oSettings.sTableId+'_previous' ); + nNext.setAttribute( 'id', oSettings.sTableId+'_next' ); + nLast.setAttribute( 'id', oSettings.sTableId+'_last' ); + } + + nInput.type = "text"; + nInput.style.width = "15px"; + nInput.style.display = "inline"; + nPage.innerHTML = "Page "; + + nPaging.appendChild( nFirst ); + nPaging.appendChild( nPrevious ); + nPaging.appendChild( nPage ); + nPaging.appendChild( nInput ); + nPaging.appendChild( nOf ); + nPaging.appendChild( nNext ); + nPaging.appendChild( nLast ); + + $(nFirst).click( function () { + oSettings.oApi._fnPageChange( oSettings, "first" ); + fnCallbackDraw( oSettings ); + } ); + + $(nPrevious).click( function() { + oSettings.oApi._fnPageChange( oSettings, "previous" ); + fnCallbackDraw( oSettings ); + } ); + + $(nNext).click( function() { + oSettings.oApi._fnPageChange( oSettings, "next" ); + fnCallbackDraw( oSettings ); + } ); + + $(nLast).click( function() { + oSettings.oApi._fnPageChange( oSettings, "last" ); + fnCallbackDraw( oSettings ); + } ); + + $(nInput).keyup( function (e) { + + if ( e.which == 38 || e.which == 39 ) + { + this.value++; + } + else if ( (e.which == 37 || e.which == 40) && this.value > 1 ) + { + this.value--; + } + + if ( this.value == "" || this.value.match(/[^0-9]/) ) + { + /* Nothing entered or non-numeric character */ + return; + } + + var iNewStart = oSettings._iDisplayLength * (this.value - 1); + if ( iNewStart > oSettings.fnRecordsDisplay() ) + { + /* Display overrun */ + oSettings._iDisplayStart = (Math.ceil((oSettings.fnRecordsDisplay()-1) / + oSettings._iDisplayLength)-1) * oSettings._iDisplayLength; + fnCallbackDraw( oSettings ); + return; + } + + oSettings._iDisplayStart = iNewStart; + fnCallbackDraw( oSettings ); + } ); + + /* Take the brutal approach to cancelling text selection */ + $('span', nPaging).bind( 'mousedown', function () { return false; } ); + $('span', nPaging).bind( 'selectstart', function () { return false; } ); + }, + + + "fnUpdate": function ( oSettings, fnCallbackDraw ) + { + if ( !oSettings.aanFeatures.p ) + { + return; + } + var iPages = Math.ceil((oSettings.fnRecordsDisplay()) / oSettings._iDisplayLength); + var iCurrentPage = Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1; + + /* Loop over each instance of the pager */ + var an = oSettings.aanFeatures.p; + for ( var i=0, iLen=an.length ; iAllan Jardine + * + * @example + * $(document).ready(function() { + * $('#example').dataTable( { + * "sPaginationType": "scrolling" + * } ); + * } ); + */ + + +/* Time between each scrolling frame */ +$.fn.dataTableExt.oPagination.iTweenTime = 100; + +$.fn.dataTableExt.oPagination.scrolling = { + "fnInit": function ( oSettings, nPaging, fnCallbackDraw ) + { + var oLang = oSettings.oLanguage.oPaginate; + var oClasses = oSettings.oClasses; + var fnClickHandler = function ( e ) { + if ( oSettings.oApi._fnPageChange( oSettings, e.data.action ) ) + { + fnCallbackDraw( oSettings ); + } + }; + + var sAppend = (!oSettings.bJUI) ? + ''+oLang.sPrevious+''+ + ''+oLang.sNext+'' + : + ''+ + ''; + $(nPaging).append( sAppend ); + + var els = $('a', nPaging); + var nPrevious = els[0], + nNext = els[1]; + + oSettings.oApi._fnBindAction( nPrevious, {action: "previous"}, function() { + /* Disallow paging event during a current paging event */ + if ( typeof oSettings.iPagingLoopStart != 'undefined' && oSettings.iPagingLoopStart != -1 ) + { + return; + } + + oSettings.iPagingLoopStart = oSettings._iDisplayStart; + oSettings.iPagingEnd = oSettings._iDisplayStart - oSettings._iDisplayLength; + + /* Correct for underrun */ + if ( oSettings.iPagingEnd < 0 ) + { + oSettings.iPagingEnd = 0; + } + + var iTween = $.fn.dataTableExt.oPagination.iTweenTime; + var innerLoop = function () { + if ( oSettings.iPagingLoopStart > oSettings.iPagingEnd ) { + oSettings.iPagingLoopStart--; + oSettings._iDisplayStart = oSettings.iPagingLoopStart; + fnCallbackDraw( oSettings ); + setTimeout( function() { innerLoop(); }, iTween ); + } else { + oSettings.iPagingLoopStart = -1; + } + }; + innerLoop(); + } ); + + oSettings.oApi._fnBindAction( nNext, {action: "next"}, function() { + /* Disallow paging event during a current paging event */ + if ( typeof oSettings.iPagingLoopStart != 'undefined' && oSettings.iPagingLoopStart != -1 ) + { + return; + } + + oSettings.iPagingLoopStart = oSettings._iDisplayStart; + + /* Make sure we are not over running the display array */ + if ( oSettings._iDisplayStart + oSettings._iDisplayLength < oSettings.fnRecordsDisplay() ) + { + oSettings.iPagingEnd = oSettings._iDisplayStart + oSettings._iDisplayLength; + } + + var iTween = $.fn.dataTableExt.oPagination.iTweenTime; + var innerLoop = function () { + if ( oSettings.iPagingLoopStart < oSettings.iPagingEnd ) { + oSettings.iPagingLoopStart++; + oSettings._iDisplayStart = oSettings.iPagingLoopStart; + fnCallbackDraw( oSettings ); + setTimeout( function() { innerLoop(); }, iTween ); + } else { + oSettings.iPagingLoopStart = -1; + } + }; + innerLoop(); + } ); + }, + + "fnUpdate": function ( oSettings, fnCallbackDraw ) + { + if ( !oSettings.aanFeatures.p ) + { + return; + } + + /* Loop over each instance of the pager */ + var an = oSettings.aanFeatures.p; + for ( var i=0, iLen=an.length ; ijneilliii + * + * @example + * $(document).ready(function() { + * $('#example').dataTable( { + * "sPaginationType": "listbox" + * } ); + * } ); + */ + +$.fn.dataTableExt.oPagination.listbox = { + /* + * Function: oPagination.listbox.fnInit + * Purpose: Initalise dom elements required for pagination with listbox input + * Returns: - + * Inputs: object:oSettings - dataTables settings object + * node:nPaging - the DIV which contains this pagination control + * function:fnCallbackDraw - draw function which must be called on update + */ + "fnInit": function (oSettings, nPaging, fnCallbackDraw) { + var nInput = document.createElement('select'); + var nPage = document.createElement('span'); + var nOf = document.createElement('span'); + nOf.className = "paginate_of"; + nPage.className = "paginate_page"; + if (oSettings.sTableId !== '') { + nPaging.setAttribute('id', oSettings.sTableId + '_paginate'); + } + nInput.style.display = "inline"; + nPage.innerHTML = "Page "; + nPaging.appendChild(nPage); + nPaging.appendChild(nInput); + nPaging.appendChild(nOf); + $(nInput).change(function (e) { // Set DataTables page property and redraw the grid on listbox change event. + window.scroll(0,0); //scroll to top of page + if (this.value === "" || this.value.match(/[^0-9]/)) { /* Nothing entered or non-numeric character */ + return; + } + var iNewStart = oSettings._iDisplayLength * (this.value - 1); + if (iNewStart > oSettings.fnRecordsDisplay()) { /* Display overrun */ + oSettings._iDisplayStart = (Math.ceil((oSettings.fnRecordsDisplay() - 1) / oSettings._iDisplayLength) - 1) * oSettings._iDisplayLength; + fnCallbackDraw(oSettings); + return; + } + oSettings._iDisplayStart = iNewStart; + fnCallbackDraw(oSettings); + }); /* Take the brutal approach to cancelling text selection */ + $('span', nPaging).bind('mousedown', function () { + return false; + }); + $('span', nPaging).bind('selectstart', function () { + return false; + }); + }, + + /* + * Function: oPagination.listbox.fnUpdate + * Purpose: Update the listbox element + * Returns: - + * Inputs: object:oSettings - dataTables settings object + * function:fnCallbackDraw - draw function which must be called on update + */ + "fnUpdate": function (oSettings, fnCallbackDraw) { + if (!oSettings.aanFeatures.p) { + return; + } + var iPages = Math.ceil((oSettings.fnRecordsDisplay()) / oSettings._iDisplayLength); + var iCurrentPage = Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1; /* Loop over each instance of the pager */ + var an = oSettings.aanFeatures.p; + for (var i = 0, iLen = an.length; i < iLen; i++) { + var spans = an[i].getElementsByTagName('span'); + var inputs = an[i].getElementsByTagName('select'); + var elSel = inputs[0]; + if(elSel.options.length != iPages) { + elSel.options.length = 0; //clear the listbox contents + for (var j = 0; j < iPages; j++) { //add the pages + var oOption = document.createElement('option'); + oOption.text = j + 1; + oOption.value = j + 1; + try { + elSel.add(oOption, null); // standards compliant; doesn't work in IE + } catch (ex) { + elSel.add(oOption); // IE only + } + } + spans[1].innerHTML = " nbsp;of nbsp;" + iPages; + } + elSel.value = iCurrentPage; + } + } +}; diff --git a/type-detection/currency.js b/type-detection/currency.js new file mode 100644 index 0000000..a49d7c0 --- /dev/null +++ b/type-detection/currency.js @@ -0,0 +1,33 @@ +/** + * This plug-in will add automatic detection for currency columns to + * DataTables. Note that only $ and £ symbols are detected with this code, + * but it is trivial to add more or change the current ones. This is best used + * in conjunction with the currency sorting plug-in. + * @name Currency + * @author Allan Jardine + */ + +jQuery.fn.dataTableExt.aTypes.unshift( + function ( sData ) + { + var sValidChars = "0123456789.-,"; + var Char; + + /* Check the numeric part */ + for ( i=1 ; ianjibman + */ + +jQuery.fn.dataTableExt.aTypes.unshift( + function ( sData ) + { + var sValidChars = "0123456789"; + var Char; + + /* Check the numeric part */ + for ( i=0 ; i<(sData.length - 3) ; i++ ) + { + Char = sData.charAt(i); + if (sValidChars.indexOf(Char) == -1) + { + return null; + } + } + + /* Check for size unit KB, MB or GB */ + if ( sData.substring(sData.length - 2, sData.length) == "KB" + || sData.substring(sData.length - 2, sData.length) == "MB" + || sData.substring(sData.length - 2, sData.length) == "GB" ) + { + return 'file-size'; + } + return null; + } +); diff --git a/type-detection/formatted-num.js b/type-detection/formatted-num.js new file mode 100644 index 0000000..015bf4d --- /dev/null +++ b/type-detection/formatted-num.js @@ -0,0 +1,21 @@ +/** + * This plug-in will strip out non-numeric formatting characters such that a + * formatted number (for example 1,000,000) can be detected automatically and + * sorted numerically. Note that characters a-z are not automatically removed, + * otherwise there is a risk of detecting columns as numeric which should not + * be. Also note that the jQuery 1.7 method isNumeric is used, so jQuery 1.7 + * is required. + * @name Formatted numbers + * @author Allan Jardine + */ + +jQuery.fn.dataTableExt.aTypes.unshift( + function ( sData ) + { + var deformatted = sData.replace(/[^\d\-\.\/a-zA-Z]/g,''); + if ( $.isNumeric( deformatted ) ) { + return 'formatted-num'; + } + return null; + } +); diff --git a/type-detection/ip-address.js b/type-detection/ip-address.js new file mode 100644 index 0000000..956ab82 --- /dev/null +++ b/type-detection/ip-address.js @@ -0,0 +1,16 @@ +/** + * Automatically detect IP addresses in dot notation. Goes perfectly with the + * IP address sorting function. + * @name IP address detection + * @author Brad Wasson + */ + +jQuery.fn.dataTableExt.aTypes.unshift( + function ( sData ) + { + if (/^\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}$/.test(sData)) { + return 'ip-address'; + } + return null; + } +); diff --git a/type-detection/num-html.js b/type-detection/num-html.js new file mode 100644 index 0000000..1836a7a --- /dev/null +++ b/type-detection/num-html.js @@ -0,0 +1,49 @@ +/** + * This type-detection plug-in will look at an HTML string from a data cell, + * strip the HTML tags and then check to see if the remaining data is numeric. + * If it is, then the data can be sorted numerically with the Numbers with HTML + * sorting plug-in. + * @name Numbers with HTML + * @author Allan Jardine + */ + +jQuery.fn.dataTableExt.aTypes.unshift( function ( sData ) +{ + sData = typeof sData.replace == 'function' ? + sData.replace( /<.*?>/g, "" ) : sData; + sData = $.trim(sData); + + var sValidFirstChars = "0123456789-"; + var sValidChars = "0123456789."; + var Char; + var bDecimal = false; + + /* Check for a valid first char (no period and allow negatives) */ + Char = sData.charAt(0); + if (sValidFirstChars.indexOf(Char) == -1) + { + return null; + } + + /* Check all the other characters are valid */ + for ( var i=1 ; iAllan Jardine + */ + +jQuery.fn.dataTableExt.aTypes.unshift( + function ( sData ) + { + var sValidChars = "0123456789-,"; + var Char; + var bDecimal = false; + + /* Check the numeric part */ + for ( i=0 ; i