row.add() cell class

row.add() cell class

CrazyYannCrazyYann Posts: 9Questions: 1Answers: 0

Hey everybody,

with the fnAddTr plug-in it's easy to define a class for a cell but this plug-in has been deprecated.So i try to do the same things with the row.add method. In this example, how to add a class to the cell called ''position''?

var table = $('#example').DataTable();
 
table.row.add( {
        "name":       "Tiger Nixon",
        "position":   "System Architect"
    } ).draw();

Thanks for responding.

This question has an accepted answers - jump to answer

Answers

  • rhinorhino Posts: 80Questions: 2Answers: 17

    Do you want the class only on the one cell, or the entire column of 'position'?

  • CrazyYannCrazyYann Posts: 9Questions: 1Answers: 0

    Only on the one cell. The cell of the new row i'd just added with the row.add method.

    Thanks for responding so quickly.

  • rhinorhino Posts: 80Questions: 2Answers: 17
    edited July 2014 Answer ✓
    var table = $('#example').DataTable();
      
    var rowNode = table.row.add( {
            "name":       "Tiger Nixon",
            "position":   "System Architect"
    } ).draw()
    .node();
     
    $( rowNode ).find('td').eq(1).addClass('myClass');
    
  • CrazyYannCrazyYann Posts: 9Questions: 1Answers: 0

    Thank you very much.

This discussion has been closed.