jQuery addClass example
Change class name on click in jQuery
by Rodrigo Pan
HTML
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.23/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/colreorder/1.5.3/css/colReorder.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/fixedcolumns/3.3.2/css/fixedColumns.dataTables.min.css">
<script src="https://cdn.datatables.net/1.10.23/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/colreorder/1.5.3/js/dataTables.colReorder.min.js"></script>
<script src="https://cdn.datatables.net/fixedcolumns/3.3.2/js/dataTables.fixedColumns.min.js"></script>
<table id="example" class="display compact cell-border" style="width:100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect with big descriptionTOColapseScrollHorrizontal</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
<tr>
<td>Garrett WintersABCDEFG</td>
<td>Accountant</td>
<td>TokyoABCDEFG HIJKLMNOP</td>
<td>63</td>
<td>2011/07/25</td>
<td>$170,750</td>
</tr>
<tr>
<td>Ashton Cox</td>
<td>Junior Technical Author</td>
<td>San Francisco</td>
<td>66</td>
<td>2009/01/12</td>
<td>$86,000</td>
</tr>
<tr>
<td>Cedric Kelly</td>
<td>Senior Javascript Developer</td>
<td>Edinburgh</td>
<td>22</td>
<td>2012/03/29</td>
...
JavaScript
$(document).ready(function() {
/*
$.fn.dataTable.FixedColumns.prototype._fnGridLayout = function ()
{
var that = this;
var oGrid = this.dom.grid;
var iWidth = $(oGrid.wrapper).width();
//var iBodyHeight = this.s.dt.nTable.parentNode.offsetHeight; //#### CHANGED ####*
var iBodyHeight = this.s.dt.nTable.parentNode.clientHeight; //#### CHANGED ####*
var iFullHeight = this.s.dt.nTable.parentNode.parentNode.offsetHeight;
var oOverflow = this._fnDTOverflow();
var iLeftWidth = this.s.iLeftWidth;
var iRightWidth = this.s.iRightWidth;
var rtl = $(this.dom.body).css('direction') === 'rtl';
var wrapper;
var scrollbarAdjust = function ( node, width ) {
if ( ! oOverflow.bar ) {
// If there is no scrollbar (Macs) we need to hide the auto scrollbar
node.style.width = (width+20)+"px";
node.style.paddingRight = "20px";
node.style.boxSizing = "border-box";
}
else if ( that._firefoxScrollError() ) {
// See the above function for why this is required
if ( $(node).height() > 34 ) {
node.style.width = (width+oOverflow.bar)+"px";
}
}
else {
// Otherwise just overflow by the scrollbar
node.style.width = (width+oOverflow.bar)+"px";
}
};
//#### CHANGED ####*
// When x scrolling - don't paint the fixed columns over the x scrollbar
//if ( oOverflow.x )
//{
// iBodyHeight -= oOverflow.bar;
//}
//#### CHANGED ####*
oGrid.wrapper.style.height = iFullHeight+"px";
if ( this.s.iLeftColumns > 0 )
{
wrapper = oGrid.left.wrapper;
wrapper.style.width = iLeftWidth+'px';
wrapper.style.height = '1px';
// Swap the position of the left and right columns for rtl (#48)
// This is always up against the edge, scrollbar on the far side
if ( rtl ) {
wrapper.style.left = '';
wrapper.style.right = 0;
}
else {
...