Datatables treats String variable like a C-string(char[])?

Datatables treats String variable like a C-string(char[])?

PneumokokPneumokok Posts: 4Questions: 0Answers: 0
edited April 2014 in General
Hi!

I saw a little bit strange behavior on Datatables plugin. In my case it treats String variable as char[] and it puts next char values into the column... Here is the code on the client-side:
[code]("#browseFriendsAndFamily").click(function(){
var contPath='<%=request.getContextPath()%>';
$.get(contPath + "/friendFamily/getFriendsByUserId",
"userId="+loggedUser.id, function(friendsList){
$("#friendFamilyDialog").dialog("open");
friendsTable = $("#friendsTable").dataTable({
"bJQueryUI": true,
"aoColumnDefs": [ {"bVisible": false, "bSortable": false, "aTargets": [3]}],
"bSortClasses": false
});
familyTable = $("#familyTable").dataTable({
"bJQueryUI": true,
"aoColumnDefs": [ {"bVisible": false, "bSortable": false, "aTargets": [3]}],
"bSortClasses": false
});
for(var i=0, length=friendsList.length; i

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    fnAddData expects an array or object of data. Not a single string with multiple parameters being passed in. That is the error that is causing what you are seeing.

    Allan
  • PneumokokPneumokok Posts: 4Questions: 0Answers: 0
    @allan
    Yes, you are right - I should use
    [code]friendsTable.fnAddData([surname, name,
    login, id]);[/code]
    Instead:
    [code]friendsTable.fnAddData(surname, name,
    login, id);[/code]
    I simply forgot about [ ] - I want to thank you very much for help because I lost 2 days for thinking what I am doing wrong :)
    Thank you again.

    With veeeery cheerful greetings,
    Pneumokok.
This discussion has been closed.