Created
February 4, 2013 09:34
-
-
Save abrambailey/4705843 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready( function () { | |
$.fn.dataTableExt.oApi.fnReloadAjax = function ( oSettings, sNewSource, fnCallback, bStandingRedraw ) | |
{ | |
if ( typeof sNewSource != 'undefined' && sNewSource != null ) { | |
oSettings.sAjaxSource = sNewSource; | |
} | |
// Server-side processing should just call fnDraw | |
if ( oSettings.oFeatures.bServerSide ) { | |
this.fnDraw(); | |
return; | |
} | |
this.oApi._fnProcessingDisplay( oSettings, true ); | |
var that = this; | |
var iStart = oSettings._iDisplayStart; | |
var aData = []; | |
this.oApi._fnServerParams( oSettings, aData ); | |
oSettings.fnServerData.call( oSettings.oInstance, oSettings.sAjaxSource, aData, function(json) { | |
/* Clear the old information from the table */ | |
that.oApi._fnClearTable( oSettings ); | |
/* Got the data - add it to the table */ | |
var aData = (oSettings.sAjaxDataProp !== "") ? | |
that.oApi._fnGetObjectDataFn( oSettings.sAjaxDataProp )( json ) : json; | |
for ( var i=0 ; i<aData.length ; i++ ) | |
{ | |
that.oApi._fnAddData( oSettings, aData[i] ); | |
} | |
oSettings.aiDisplay = oSettings.aiDisplayMaster.slice(); | |
if ( typeof bStandingRedraw != 'undefined' && bStandingRedraw === true ) | |
{ | |
oSettings._iDisplayStart = iStart; | |
that.fnDraw( false ); | |
} | |
else | |
{ | |
that.fnDraw(); | |
} | |
that.oApi._fnProcessingDisplay( oSettings, false ); | |
/* Callback user function - for event handlers etc */ | |
if ( typeof fnCallback == 'function' && fnCallback != null ) | |
{ | |
fnCallback( oSettings ); | |
} | |
}, oSettings ); | |
}; | |
jQuery.fn.dataTableExt.oSort['num-html-asc'] = function(a,b) { | |
var x = a.replace( /<.*?>/g, "" ); | |
var y = b.replace( /<.*?>/g, "" ); | |
x = parseFloat( x ); | |
y = parseFloat( y ); | |
return ((x < y) ? -1 : ((x > y) ? 1 : 0)); | |
}; | |
jQuery.fn.dataTableExt.oSort['num-html-desc'] = function(a,b) { | |
var x = a.replace( /<.*?>/g, "" ); | |
var y = b.replace( /<.*?>/g, "" ); | |
x = parseFloat( x ); | |
y = parseFloat( y ); | |
return ((x < y) ? 1 : ((x > y) ? -1 : 0)); | |
}; | |
var oTable = $('#devices').dataTable({ | |
"bProcessing": true, | |
"bServerSide": true, | |
"sAjaxSource": "<%= overalljson_url(format: 'json') %>", | |
"aaSorting": [[ 5, "asc" ]] | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment