Last active
December 13, 2015 17:59
-
-
Save gustinmi/4952465 to your computer and use it in GitHub Desktop.
jQuery Tables plugin. Below is the code that triggers the update ajax source via your own custom event handler, possibly passing http paramaters.
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
//This is the extension function for table plugin (My params are array of key value pairs). Make this script available to your //web page which is utilizing the table plugin | |
$.fn.dataTableExt.oApi.fnReloadAjax = function (oSettings, sNewSource, myParams ) { | |
if ( oSettings.oFeatures.bServerSide ) { | |
oSettings.aoServerParams = []; | |
oSettings.aoServerParams.push({"sName": "user", | |
"fn": function (aoData) { | |
for (var i=0;i<myParams.length;i++){ | |
aoData.push( {"name" : myParams[i][0], "value" : myParams[i][1]}); | |
} | |
}}); | |
this.fnClearTable(oSettings); | |
this.fnDraw(); | |
return; | |
} | |
}; | |
//Example usage to put in you refresh event listener | |
var oTable; | |
if (oTable == null) { | |
oTable = $(".items").dataTable(); //code for your data table | |
}else{ | |
oTable.fnReloadAjax(oTable.oSettings, supplier, val); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment