testing _fnCallbackReg
by FirstBug
HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/dataTables.bootstrap.min.css">
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js"></script>
<script src="https://cdn.datatables.net/1.10.16/js/dataTables.bootstrap.min.js"></script>
<table id="example" class="table table-striped table-bordered" cellspacing="0"></table>
CSS
body {
font-size: 140%;
padding: 1em;
}
.px200 {
width: 200px;
max-width: 200px;
min-width: 200px;
word-wrap: break-word;
}
JavaScript
(function(window, document, $, undefined) {
//
//
$(document).on('init.dt', function(e, oSettings) {
var tCreated = function(row, data, dataIndex) {
console.log('row', row);
$(row).addClass('test') ;
};
oSettings.oApi._fnCallbackReg(oSettings, 'aoRowCreatedCallback', tCreated, 'user');
});
//
//
})(window, document, jQuery);
$(document).ready(function() {
var table = $('#example').DataTable({
'autoWidth': false,
'scrollX': 'true',
'scrollY': 300,
'scrollCollapse': true,
columns: [{
data: 'name',
title: 'Long Name Issues',
className: 'px200',
render: function(data) {
return '<span class="">' + data + '</span>';
}
}, {
data: 'position',
title: 'Position',
className: 'px200',
}, {
data: 'description',
title: 'Long Description Issues',
className: 'px200',
render: function(data) {
return data;
}
}, {
data: 'salary',
title: 'salary May have Big Title',
className: 'px200',
}, {
data: 'age',
title: 'age',
className: 'px200',
}],
data: [{
name: 'Amber',
position: 'CEO',
description: 'SOME long description with spaces SOME long description with spaces',
salary: '1000',
age: '45'
}],
});
});