fnInitComplete to get access to already initialized dataTable not working as expected?
fnInitComplete to get access to already initialized dataTable not working as expected?
In Page load, I have initialized dataTable and fnInitComplete have called as expected.
Then I have clicked button, now I have passed result to already initialized dataTable(Using bRetrieve = true).
Now fnInitComplete isn't working in after initialized dataTable.
How to work fnInitComplete in bRetrieve?
I can't do that below issue in Test case. That's why i have posted my sample code.
My sample coding:
$(document).ready(function() {
//Now fnInitComplete is working. I got the alert now
var result = $.parseJSON(result);
var oTable = initTable();
BuildTopAccounts(result);
//Now fnInitComplete isn't working
$('.Buttons').click(function(){
var result = $.parseJSON(result);
var oTable = initTable();
BuildTopAccounts(result);
}};
} );
function initTable (){
return $('#contacttable').dataTable({
"sScrollY": calcDataTableHeight(),
"bAutoWidth": true,
"sScrollX": "800",
"bRetrieve": true,
"bDeferRender": true,
"aoColumnDefs": [
{"fnRender": getRank,"mDataProp": "rank", "sType": "Rank", "aTargets": [ 0 ],sDefaultContent: ""},
{"fnRender": getName,"sClass": "Name", "mDataProp": "Name", "bUseRendered":false,"aTargets": [ 1 ],sDefaultContent: ""}
],
"fnInitComplete": function (o) {
alert('fnInitComplete');
}
});
}
function BuildTopAccounts(result){
$('#contacttable').dataTable().fnClearTable();
$('#contacttable').dataTable().fnAddData(result);
}
Then I have clicked button, now I have passed result to already initialized dataTable(Using bRetrieve = true).
Now fnInitComplete isn't working in after initialized dataTable.
How to work fnInitComplete in bRetrieve?
I can't do that below issue in Test case. That's why i have posted my sample code.
My sample coding:
$(document).ready(function() {
//Now fnInitComplete is working. I got the alert now
var result = $.parseJSON(result);
var oTable = initTable();
BuildTopAccounts(result);
//Now fnInitComplete isn't working
$('.Buttons').click(function(){
var result = $.parseJSON(result);
var oTable = initTable();
BuildTopAccounts(result);
}};
} );
function initTable (){
return $('#contacttable').dataTable({
"sScrollY": calcDataTableHeight(),
"bAutoWidth": true,
"sScrollX": "800",
"bRetrieve": true,
"bDeferRender": true,
"aoColumnDefs": [
{"fnRender": getRank,"mDataProp": "rank", "sType": "Rank", "aTargets": [ 0 ],sDefaultContent: ""},
{"fnRender": getName,"sClass": "Name", "mDataProp": "Name", "bUseRendered":false,"aTargets": [ 1 ],sDefaultContent: ""}
],
"fnInitComplete": function (o) {
alert('fnInitComplete');
}
});
}
function BuildTopAccounts(result){
$('#contacttable').dataTable().fnClearTable();
$('#contacttable').dataTable().fnAddData(result);
}
This discussion has been closed.
Replies
Allan
How to destroy or delete the old table values and again initialize table in new for passing table result.
Because I need fnInitComplete for bRetrieve = true?
Is it possible to do that?