Adding rows in a particular context doesn't work

Adding rows in a particular context doesn't work

mysthiqmysthiq Posts: 4Questions: 1Answers: 0

As said in that post on StackOverflow ...

http://stackoverflow.com/questions/33871984/datatables-using-fncreatedrow-to-add-details-rows

When i use

dataTable.row.add($myRow);

It gives me that error :

TypeError: invalid 'in' operand a

If I remove the fourth td of the row that I want to add... there is no error.
In my JSON response from the server, the fourth column contains an array of array that contains the sub rows that I want to add via the createdRow callback.

Any idea ?

Answers

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75
    edited November 2015

    Were gonna need the content of $myRow...

    Whi h if youre following the common variable naming structure, the $ means its a jQuery object, which wouldnt be right, it needs to be an array or object

  • mysthiqmysthiq Posts: 4Questions: 1Answers: 0

    Here it is !

    dataTable.row.add($(nRow).clone()[0].outerHTML);
    

    nRow being the first parameter of the callback createdRow...

  • mysthiqmysthiq Posts: 4Questions: 1Answers: 0
    edited November 2015

    I saw that in a comment of the row.add() page that we can put a jQuery object :
    https://datatables.net/reference/api/row.add()

    I have succeed to make it work on a simple example in a fiddle http://jsfiddle.net/0f9Ljfjr/740/

    So...yes it's possible.

  • mysthiqmysthiq Posts: 4Questions: 1Answers: 0

    It works now ...but I don't know what i'd changed ... So i can't give the answer for others :(

This discussion has been closed.