if ( iDivY + iDivHeight > iDocHeight )
{
nHidden.style.top = (iDivY-iDivHeight-$(nButton).outerHeight())+"px";
}
var iDivY = parseInt(oPos.top + $(this.dom.button).outerHeight(), 10);
TableTools_Button TableTools_text_hover TableTools_collectionBackground Button disabled
"aoGroups": [{"sName": "name display label here", "aiTargets": [list of int, col numbers]}]
/** * List of columns (integers) which should be grouped together and use Group Name on the button * @property aoGroups * @type Array * @default [] */ "aoGroups": []
/**
* Loop through the columns in the table and as a new button for each one.
* @method _fnFindGroup
* @param {int} target Column in question
* @returns {Node} Group
* @private
*/
"_fnFindGroup": function ( target )
{
var
aiTargets, nGroup,
aoGroups = this.s.aoGroups;
for ( var i=0, iLen=aoGroups.length ; i<iLen ; i++ )
{
nGroup = aoGroups[ i ];
aiTargets = nGroup.aiTargets;
if ((typeof aiTargets != "undefined")&&(aiTargets.length>0))
{
if (target == aiTargets[0])
{
if (typeof nGroup.sName == "undefined")
{
nGroup.sName = this.s.dt.aoColumns[target].sTitle;
}
return nGroup;
}
else
{
if (typeof nGroup.extra == "undefined")
{
nGroup.extra = ","+aiTargets.slice(1).join(',')+",";
}
if ( nGroup.extra.indexOf( ","+target+"," ) != -1 )
{
return null;
}
}
}
}
return {"sName": this.s.dt.aoColumns[target].sTitle, "aiTargets": [target]};
},
"_fnAddButtons": function ()
{
var
nGroup, nButton,
sExclude = ","+this.s.aiExclude.join(',')+",";
for ( var i=0, iLen=this.s.dt.aoColumns.length ; i<iLen ; i++ )
{
if (( sExclude.indexOf( ","+i+"," ) == -1 )&&( (nGroup = this._fnFindGroup( i )) != null ))
{
nButton = this._fnDomColumnButton( nGroup );
this.dom.buttons.push( nButton );
this.dom.collection.appendChild( nButton );
}
else
{
this.dom.buttons.push( null );
}
}
},
/**
* Create the DOM for a show / hide button
* @method _fnDomColumnButton
* @param {Node} nGroup Group in question
* @returns {Node} Created button
* @private
*/
"_fnDomColumnButton": function ( nGroup )
{
var
that = this,
nButton = document.createElement('button'),
nSpan = document.createElement('span');
nButton.className = !this.s.dt.bJUI ? "ColVis_Button TableTools_Button" :
"ColVis_Button TableTools_Button ui-button ui-state-default";
nButton.appendChild( nSpan );
$(nSpan).html(
'<span class="ColVis_radio"><input type="checkbox"></span>'+
'<span class="ColVis_title">'+nGroup.sName+'</span>' );
$(nButton).click( function (e) {
var showHide = $('input',this).attr('checked')===true ? false : true;
if ( e.target.nodeName.toLowerCase() == "input" )
{
showHide = $('input',this).attr('checked');
}
/* Need to consider the case where the initialiser created more than one table - change the
* API index that DataTables is using
*/
var oldIndex = $.fn.dataTableExt.iApiIndex;
$.fn.dataTableExt.iApiIndex = that._fnDataTablesApiIndex.call(that);
for ( var i=0, iLen=nGroup.aiTargets.length ; i<iLen ; i++ )
that.s.dt.oInstance.fnSetColumnVis( nGroup.aiTargets[i], showHide );
$.fn.dataTableExt.iApiIndex = oldIndex; /* Restore */
} );
return nButton;
},
/* Do a redraw incase anything depending on the table columns needs it * (built-in: scrolling) */ _fnAjustColumnSizing( oSettings ); _fnDraw( oSettings ); _fnSaveState( oSettings );So it's needed to get the column sizes right, although we can get away without it when not using DataTables' scrolling options. At that point this code could be commented out. I've been thinking about making this an option in this function, and that could be passed up stream to ColVis. I've made a note in my to-do list.
"fnInitComplete": function() {
this.fnSettings().oFeatures.bServerSide = false;
this.fnSettings().sAjaxSource = null;
},
if ( oSettings.oFeatures.bServerSide )
{
iStart = 0;
iEnd = oSettings.aoData.length;
}
function _fnDraw( oSettings, noAjax )
if ( oSettings.oFeatures.bServerSide && typeof noAjax == 'undefined' && !_fnAjaxUpdate( oSettings ) )
if ( oSettings.oFeatures.bServerSide ) {
_fnDraw( oSettings, true );
}
else {
_fnDraw( oSettings );
}
if ( typeof oConfig.aoGroups != 'undefined' )
{
this.s.aoGroups = oConfig.aoGroups;
}
if ( jQuery.browser.msie && jQuery.browser.version == "7.0" ) {
$(nBackground).css('background-color', 'white');
}
I honestly have no clue why exactly this works only with additional background set - I tried to debug it with some "hello world" output at first and wanted to emphasize its display with red background (IE7/IE8 debugging options are clearly devastating). As my application's background is mostly white or very light grey, setting this element's background to a fixed color didn't hurt me. But still: maybe there is a better solution available...if ( typeof oConfig.bRestore != 'undefined' )
{
this.s.bRestore = oConfig.bRestore;
}
<label><input type="checkbox" class="cb" id="0" checked="checked" /> Company</label> <label><input type="checkbox" class="cb" id="1" checked="checked" /> Description</label> <label><input type="checkbox" class="cb" id="2" checked="checked" /> URL</label>
$("input[type='checkbox'].cb").change(function() {
var checked = $(this).is(":checked");
var id = $(this).attr("id");
dTable.fnSetColumnVis(id, checked);
});
It looks like you're new here. If you want to get involved, click one of these buttons!
Get useful and friendly help straight from the source.