Data table not show on IE7 with Ajax Json

Data table not show on IE7 with Ajax Json

tgptgp Posts: 13Questions: 0Answers: 0
edited May 2009 in General
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.

Replies

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    Hi tgp,

    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
  • tgptgp Posts: 13Questions: 0Answers: 0
    Hi Allan, they are 7 columns and this is the code:

    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
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    Hi,

    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
  • tgptgp Posts: 13Questions: 0Answers: 0
    Hi,
    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.
  • tgptgp Posts: 13Questions: 0Answers: 0
    sorry i fotget to tell that I add to the end:
    $var .= '] }';
    then return the full code to Datatable
  • tgptgp Posts: 13Questions: 0Answers: 0
    Sorry againg :S I think you was tell me about the JSON code but I see is the HTML code, I will chekc it an test it.

    It works!!! :D

    Thanks a lot.
This discussion has been closed.