DataTables / DataTablesSrc

DataTables source repository
https://datatables.net
MIT License
628 stars 423 forks source link

"Cannot read property 'id'" of nTr error #147

Open liquidaty opened 5 years ago

liquidaty commented 5 years ago

This issue can occur when a $row.data(new_data) is called on a row whose TR element has not been rendered (e.g. my table has 500 rows, I've only rendered the first page, and I'm going to modify row 350). The offending line is in api.rows.js:

        if ( $.isArray( data ) && row.nTr.id ) {
            _fnSetObjectDataFn( ctx[0].rowId )( data, row.nTr.id );
        }

Assuming that _fnSetObjectDataFn does not need to be called in these circumstances, would the below change be sufficient to fix the issue?

        if ( $.isArray( data ) && row.nTr && row.nTr.id ) {
            _fnSetObjectDataFn( ctx[0].rowId )( data, row.nTr.id );
        }
DataTables commented 5 years ago

Hi - thanks for posting this. Can you link to an example showing the issue please?

Thanks, Allan