Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  7] [ 3]  / answers: 1 / hits: 29862  / 13 Years ago, fri, march 2, 2012, 12:00:00

I am using a function 'fnDrawCallback' for page change. It basically solves my purpose. The only thing is I have to specify that function when I am initializing dataTable object. Is there any way I can do it after initialization?



For Example:
I am doing like this:



$(#tableID).dataTables({'fnDrawCallBack':functionName});


I want to do like this:



var oTable = $(#tableID).dataTables();
oTable.fnDrawCallback = functionName; // or something like this


Solution:



oTable.aoDrawCallback.push(functionObj);
var functionObj = {
fn: funtionName
};

More From » jquery

 Answers
7

You could access the internal data settings of DataTables to manipulate the draw callback array (aoDrawCallback, not fnDrawCallback internally - its an array since there can be multiple callbacks), or (and what I would suggest) you can add a 'draw' event listener:



var oTable = $(#tableID).dataTables();
$(oTable).bind( 'draw', functionName );


The events fired by DataTables are documented here: http://datatables.net/docs/DataTables/1.9.0/#summary_events


[#87081] Thursday, March 1, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
estefanib

Total Points: 508
Total Questions: 104
Total Answers: 83

Location: Lebanon
Member since Sun, Aug 2, 2020
4 Years ago
;