How can i add a row in a datatable with child rows (show extra / detailed information)

How can i add a row in a datatable with child rows (show extra / detailed information)

rvzyonrvzyon Posts: 2Questions: 1Answers: 0

Link to test case: datatable with child rows
Debugger code (debug.datatables.net):
Error messages shown: DataTables warning: table id=example - Requested unknown parameter 'name' for row 5, column 1. For more information about this error, please see http://datatables.net/tn/4
Description of problem: I have the message error when i try to add a row with this function :

$('#addRow').on( 'click', function () {
table.row.add([
{
"id": '900',
"name": "Herve Zyon",
"position": "Accountant",
"salary": "$162,700",
"start_date": "2008/11/28",
"office": "Tokyo",
"extn": "5407"
}
] ).draw( false );

} );

I don't know how to feel the first column which contains an image by the function above.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,171Questions: 26Answers: 4,922
    Answer ✓

    row.add() expects only one row of data so you don't want to put it in an array. Where rows.add() expects one or more rows and looks for the rows to be in an array. With rows.add() just pass the object as the parameter, like this:

    table.row.add(
        {
            "id": '900',
            "name": "Herve Zyon",
            "position": "Accountant",
            "salary": "$162,700",
            "start_date": "2008/11/28",
            "office": "Tokyo",
            "extn": "5407"
        }
    ).draw( false );
    

    Kevin

  • rvzyonrvzyon Posts: 2Questions: 1Answers: 0

    Thanks!

This discussion has been closed.