Data table not show on IE7 with Ajax Json
Data table not show on IE7 with Ajax Json
Hi Allan, i'm using Datatables with Ajax Json and it works very well on Firefox but I try it today on IE7 and it add a null colum on the end and show me the message Data Tables error - colums does not match.
I read the post:
http://datatables.net/forums/comments.php?DiscussionID=102&page=1#Item_5
and test the Json generated code by my php script on http://www.jsonlint.com/ and the result was ok, then I think it is a IE7 bug but may be you can test it to make a hack or patch.
I read the post:
http://datatables.net/forums/comments.php?DiscussionID=102&page=1#Item_5
and test the Json generated code by my php script on http://www.jsonlint.com/ and the result was ok, then I think it is a IE7 bug but may be you can test it to make a hack or patch.
This discussion has been closed.
Replies
I'm not quite sure I follow - you put an extra column (whose value is null) into your json return, and DataTables is giving an alert about the columns not matching - is the answer not there? :-)
DataTables requires that the json return gives information about the exact number of columns that it knows about, including hidden columns. Otherwise it will reject that information as either incomplete or to much information and doesn't know what should go where.
So it would appear that the answer is to remove this null value. Could you post an example please, that might help me understand what is going on.
Thanks,
Allan
JAVASCRIPT:
"aoColumns": [
{ "sType": "natural", "bSearchable": true, "bSortable": true, "sClass": "ajaxlink", "sWidth": "30px"}, //1. No.
{ "sType": "natural", "bSearchable": true, "bSortable": true, "sWidth": "100px" }, // 2. id_cuenta
{ "sType": "natural", "bSearchable": true, "bSortable": true, "sClass": "ajaxlink", "sWidth": "250px" }, // 3. nombre
{ "bSearchable": false, "bSortable": true, "sWidth": "50px" }, // 4. Saldo1
{ "bSearchable": true, "bSortable": true, "sWidth": "100px" }, // 5. Tipologia
{ "sType": "html", "sWidth": "150px" }, // 6. Ultima transaccion
{ "sType": "natural", "bSearchable": false, "bSortable": true, "bVisible": false, "sClass": "ajaxlink", "sWidth": "30px"}, // 7. Ultima transaccion timstamp
],
HTML:
No.
Cuenta No.
Nombre
Saldo
Tipolog
You have a trailing comma in your aoColumns array (""30px"}, // 7. Ultima transaccion timstamp").
That comma is not valid, because it's suggesting that there will be another element in the array - but there isn't. So just remove the tailing comma and that should do it.
Allan
Oh yes you have reason but i remove that tailing comma with this:
$var = substr_replace( $var, "", -1 );
where var is the full JSON code above.
$var .= '] }';
then return the full code to Datatable
It works!!! :D
Thanks a lot.