1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
<?xml version="1.0" encoding="UTF-8" ?>
<dt-api group="columns">
<name>column().visible()</name>
<summary>Get / set the visibility of a single selected column.</summary>
<since>1.10</since>
<type type="function">
<signature>column().visible()</signature>
<description>Get the visibility of the selected column.</description>
<returns type="boolean">`true` if the column is visible, `false` if it is not.</returns>
</type>
<type type="function">
<signature>column().visible( show [, redrawCalculations ] )</signature>
<description>Set the visibility of the selected column.</description>
<parameter type="boolean" name="show">
Specify if the column should be visible (`true`) or not (`false`).
</parameter>
<parameter type="boolean" name="redrawCalculations" default="true">
Indicate if DataTables should recalculate the column layout (`true` - default) or not (`false`). Typically this would be left as the default value, but it can be useful to disable when using the method in a loop - so the calculations are performed on every call as they can hamper performance.
</parameter>
<returns type="DataTables.Api">DataTables API instance with selected column in the result set.</returns>
</type>
<description>
Showing and hiding columns in a DataTable can be quite handy, particularly when showing tables with a large information density. This method allows the visibility of a single column to be changed on-the-fly, or the visibility state of a column to be read.
</description>
<example title="Get the visiblity status of column index 0"><![CDATA[
var table = $('#example').DataTable();
alert( 'Column index 0 is '+
(table.column( 0 ).visible() === true ? 'visible' : 'not visible')
);
]]></example>
<example title="Hide the first column in the table"><![CDATA[
var table = $('#example').DataTable();
table.column( 0 ).visible( false );
]]></example>
<example title="Hide multiple columns using `redrawCalculations` to improve performance"><![CDATA[
var table = $('#example').DataTable();
for ( var i=0 ; i<4 ; i++ ) {
table.column( i ).visible( false, false );
}
table.columns.adjust().draw( false ); // adjust column sizing and redraw
]]></example>
<related type="api">columns().visible()</related>
</dt-api>
|