Problem with nfServerData

Problem with nfServerData

poutchyoukpoutchyouk Posts: 17Questions: 0Answers: 0
edited June 2013 in General
Hello,

I already posted this question here ( http://www.datatables.net/forums/discussion/16150/nfserverdata-not-called-#Item_1 ), but my explanation was not good at all.
Apologies for the double post, here is my question:
Isn't the fnDraw function supposed to call the function set via fnServerData at each of his calls ?
If yes, why is this code not working:
Init of the "Master" table:
[code]function InitTopDataTable() {
TopTable = $("#TopTable").dataTable({
"bJQueryUI": true,
"bServeSide": true,
"bProcessing": true,
"sAjaxSource": "Home/GetTopTable",
"fnServerData": function (sSource, aoData, fnCallback, oSettings) {
console.log("Start update top");
$.getJSON(sSource, aoData, function (json) {
fnCallback(json)
});
console.log("End update top");
}
});
}[/code]
Init of the "Slave" table
[code]function InitBotDataTable() {
BotTable = $("#BotTable").dataTable({
"bPaginate": false,
"bJQueryUI": true,
"bServeSide": true,
"bProcessing": true,
"sAjaxSource": "Home/GetBotTable",
"fnServerData": function (sSource, aoData, fnCallback, oSettings) {
console.log("Start update bot with id = " + MasterRecordID);
aoData.push({ "name": "value", "value": MasterRecordID });
$.getJSON(sSource, aoData, function (json) {
fnCallback(json)
});
console.log("End update bot");
}
});
[/code]
Handling of a click on the master table
[code]TopTable.on("click", "tbody tr", function (e) {
MasterRecordID = this.rowIndex;
console.log("Calling bot update");
BotTable.fnDraw();
})
[/code]
Thanks for any help

Replies

  • poutchyoukpoutchyouk Posts: 17Questions: 0Answers: 0
    edited June 2013
    I can finally give you access to the web site.
    Here it is:
    http://sms.mayeur.eu/
    Note: The second table do not work on IE8. Fixing it might help :)
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    > "bServeSide": true,

    There is a typo there. It should be `bServerSide` (missing the second `r` ).

    Allan
  • poutchyoukpoutchyouk Posts: 17Questions: 0Answers: 0
    Thanks a lot ! That was so obvious I couldn't see it !
    I have one last question.
    I periodically refresh my tables and it causes it to blink a little. Is there a way to do an "instant refresh" after the datas are fetched ?
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    It should already be doing that. It will remove the old rows and then add the new ones only when the new data has been retrieved. The loading message will flash up for a moment since you have that enabled.

    Allan
This discussion has been closed.