DataTables v2.0.2 vs 1.13.7 -- addClass

DataTables v2.0.2 vs 1.13.7 -- addClass

joycentiongjoycentiong Posts: 6Questions: 2Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
None
Description of problem:

I upgraded dataTables to 2.0.2 from 1.13.7. Here are the sample codes when adding an empty row in the table.

let newRow = config.createEmptyRow(); // create an empty row.

let x = config.table.row.add(newRow);
        if (x != null) {
            let rowIndex = x.index();
            $(x.node()).addClass("new").addClass("changed");
            x.draw();
        }

Html: Sample codes using 1.13.7:


Html: Sample codes using 2.0.2:

It does add a class attr but no values.

Thanks.

This question has an accepted answers - jump to answer

Answers

  • joycentiongjoycentiong Posts: 6Questions: 2Answers: 0

    Sorry, not sure why the image appear multiple times.

  • kthorngrenkthorngren Posts: 21,289Questions: 26Answers: 4,943
    edited March 20 Answer ✓

    In Datatables 2.0 the deferRender option is turned off by default. This means the row().node() (x.node()) is not availalbe until the row is shown on the page. You will need to revert to the 1.10 default by setting deferRender: false.

    Kevin

  • joycentiongjoycentiong Posts: 6Questions: 2Answers: 0

    Thanks.

Sign In or Register to comment.