Can't load new table from ajax

Can't load new table from ajax

thetomthetom Posts: 9Questions: 0Answers: 0
edited February 2013 in General
Hello everybody and thanks again to everyone involved in the developing and manteining of this software.
I'm having a problem while re-creating my datatable with json data. The Json i'm sending contains aaData array and aoColumns array.
Every time the number of columns changes i get this error: TypeError: a.aoColumns[m] is undefined
I think it's because the number of columns changes, but it sounds strange to me because i send every time the new set of options for aoColumns.
Can someone please tell me how to fix that? thank you!

Here's my debug page:
http://debug.datatables.net/umaguj
And here's the code i'm using when creating the table:
HTML:
[code]






[/code]
Javascript:
[code]
function riempiTabella(idCategoria){
apriProgressBarModal();
$.ajax( {
xhr: function(){
var xhr = new window.XMLHttpRequest();
//Download progress
xhr.addEventListener("progress", function(evt){
if (evt.lengthComputable) {
var percentComplete = evt.loaded / evt.total;
//Do something with download progress
aggiornaProgressBarModal((percentComplete*100)| 0);
}
}, false);
return xhr;
},
"url": cUrlHttp + "ricetom1.asp?TK_TOKEN=&TK_DBASE=M&TK_UTEN=" + cUten + "&TK_TDV="+idCategoria+"&TK_STRI=&TK_CAMP=",
"dataType": "json",
"success": function ( json ) {
json.sScrollX="100%";
json.bScrollCollapse=true;
json.sDom="<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>";
json.bProcessing=true;
json.bDestroy=true;
tabella=$('#tabellaView').dataTable( json );
chiudiProgressBarModal();
}
} );
}
[/code]

Replies

  • thetomthetom Posts: 9Questions: 0Answers: 0
    I just figured out that I was sending a wrong Json, it had 2 same objects for every aaData entry. Now i fixed that, but i have still the same problem. I hope someone could help me.. Thank you in advance!
  • thetomthetom Posts: 9Questions: 0Answers: 0
    I fixed it on my own.
    The solution was to delete thead and tbody after table destruction and recreate them for the new table.
    [code]
    tabella.fnDestroy();
    $("#tabellaView").children().remove();
    $("#tabellaView").children().first().html("tbody>");
    tabella=null;
    [/code]
This discussion has been closed.