jQuery datatables add class to tr

$('tr', row) is looking for a tr element in the context of row, meaning it will search for a tr element inside the row provided as context parameter.

According to API, this should work

$(row).addClass("label-warning");

You would just have to use the createdRow

$('#data-table').DataTable( {
    createdRow: function( row, data, dataIndex ) {
        // Set the data-status attribute, and add a class
        $( row ).find('td:eq(0)')
            .attr('data-status', data.status ? 'locked' : 'unlocked')
            .addClass('asset-context box');
    }
} );

To set the Id attribute on the row <tr> use:

//.... 
rowId: "ShipmentId",
columns: [...],
//....

To set a class name on the <tr> use this calback

createdRow: function (row, data, dataIndex) {
    $(row).addClass('some-class-name');
},

ref: https://datatables.net/reference/option/createdRow

To set a class on the <td> use

"columns": [
{ 
    data:"",
    className: "my_class",
    render: function (data, type, row) { return "..."; }
},
{ 
    data:"",
    className: "my_class",
    render: function (data, type, row) { return "..."; }
},
//...
]

Something similar for 'columnDefs'

ref: https://datatables.net/reference/option/columns.className


DataTable().row.add() situation:

If you want to add class when using row add function in Datatables, you could get the TR-DOM from node() method:

var datatable = $('#resultTable').DataTable();

var trDOM = datatable.row.add( [
    "Col-1",
    "Col-2"
] ).draw().node();

$( trDOM ).addClass('myClass');