Quantcast
Channel: DataTables 1.10 — DataTables forums
Viewing all articles
Browse latest Browse all 2364

How does one catch the first draw event?

$
0
0

I initialize a table and seem to have missed the first draw event, I think because I have to create the on('draw' after the table is first initialized.

What is the technique required to catch the first draw event?

See http://codepen.io/louking/pen/MKPpwx

var data = []
for (i=1; i<30; i++) {
  data.push ({a:'a'+i, b:'b'+i, c:'c'+i})
}

var table = $('#tbl').DataTable({
  data: data,
  columns: [{ data: 'a' }, 
            { data: 'b', 
             render: function(d,t,r,m) {
               return '<span class="make-red">' + 
                 d + '</span>';
             }
            }, 
            { data: 'c' }],

});

table.on('draw', function () {
  $('.make-red').addClass('red');
})
<table id=tbl>
  <thead>
    <tr>
      <th>col0</th>
      <th>col1</th>
      <th>col2</th>
    </tr>
  </thead>
  <tbody>
  </tbody>
</table>
.red {color:red};

Viewing all articles
Browse latest Browse all 2364

Trending Articles