Problem with nfServerData
Problem with nfServerData
poutchyouk
Posts: 17Questions: 0Answers: 0
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
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
This discussion has been closed.
Replies
Here it is:
http://sms.mayeur.eu/
Note: The second table do not work on IE8. Fixing it might help :)
There is a typo there. It should be `bServerSide` (missing the second `r` ).
Allan
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 ?
Allan