1.8 upgrade to 1.9.3 --> fnRowCallback not run

1.8 upgrade to 1.9.3 --> fnRowCallback not run

pcfungpcfung Posts: 1Questions: 0Answers: 0
edited September 2012 in DataTables 1.9
When i click the button.
It's success to reload datatable and have console return (TR....) on version 1.8.
On version 1.9.3, it's just reload datatable but console on response (also no console error).
Please help me to fix it, i want upgrade to 1.9.3
Many thx...!!

[code]

$(document).ready(function() {
$('button').click(function(e){
var oSetting = oTable.fnSettings();
oSettings.fnServerData = function(sSource, aoData, fnCallback){
$.ajax({
"dataType": "json",
"type": "GET",
"url": sSource,
"data": aoData,
"success": function(j){
fnCallback(j);
}
});
};
//console.log(oSettings.fnRowCallback); -->undefined (ver.:1.8 & 1.9.3)
oSettings.fnRowCallback = function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
console.log(nRow);
...
...
...
};
//console.log(oSettings.fnRowCallback); -->function() (ver.:1.8 & 1.9.3)
oTable.fnDraw();
});

var oTable = $('#example').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "get_json.php",
});
};

[/code]

Replies

  • ekstseekstse Posts: 1Questions: 0Answers: 0
    encountered same problem here, nothing happend in fnRowCallback after upgrading to 1.9.3
  • allanallan Posts: 63,395Questions: 1Answers: 10,451 Site admin
    > oSettings.fnRowCallback

    This is not a valid way to set fnRowCallback. oSettings is the private settings store for DataTables and its properties are private to the instance. They are liable to change between major (and even minor) versions, as has been done in 1.9 to make things more flexible. Please use the publicly published API to avoid having issues with upgrades like this (its fine of course to use the private properties, if you know how they work - but that aren't guaranteed to work between versions unlike the pubic API).

    The only public API to use for fnRowCallback is the fnRowCallback initialisation method. If you need to alter the function that is called, as is done above, then you'll need a closure with the private function being overwritten.

    [code]
    var myFunction = function () {};

    $('#example').dataTable( {
    fnRowCallback function (...) {
    myFunction.apply( this, arguments );
    }
    } );
    [/code]

    For example.

    Allan
This discussion has been closed.