( settings, column, vis )
| 7885 | |
| 7886 | |
| 7887 | var __setColumnVis = function ( settings, column, vis ) { |
| 7888 | var |
| 7889 | cols = settings.aoColumns, |
| 7890 | col = cols[ column ], |
| 7891 | data = settings.aoData, |
| 7892 | row, cells, i, ien, tr; |
| 7893 | |
| 7894 | // Get |
| 7895 | if ( vis === undefined ) { |
| 7896 | return col.bVisible; |
| 7897 | } |
| 7898 | |
| 7899 | // Set |
| 7900 | // No change |
| 7901 | if ( col.bVisible === vis ) { |
| 7902 | return; |
| 7903 | } |
| 7904 | |
| 7905 | if ( vis ) { |
| 7906 | // Insert column |
| 7907 | // Need to decide if we should use appendChild or insertBefore |
| 7908 | var insertBefore = $.inArray( true, _pluck(cols, 'bVisible'), column+1 ); |
| 7909 | |
| 7910 | for ( i=0, ien=data.length ; i<ien ; i++ ) { |
| 7911 | tr = data[i].nTr; |
| 7912 | cells = data[i].anCells; |
| 7913 | |
| 7914 | if ( tr ) { |
| 7915 | // insertBefore can act like appendChild if 2nd arg is null |
| 7916 | tr.insertBefore( cells[ column ], cells[ insertBefore ] || null ); |
| 7917 | } |
| 7918 | } |
| 7919 | } |
| 7920 | else { |
| 7921 | // Remove column |
| 7922 | $( _pluck( settings.aoData, 'anCells', column ) ).detach(); |
| 7923 | |
| 7924 | col.bVisible = false; |
| 7925 | _fnDrawHead( settings, settings.aoHeader ); |
| 7926 | _fnDrawHead( settings, settings.aoFooter ); |
| 7927 | |
| 7928 | _fnSaveState( settings ); |
| 7929 | } |
| 7930 | |
| 7931 | // Common actions |
| 7932 | col.bVisible = vis; |
| 7933 | _fnDrawHead( settings, settings.aoHeader ); |
| 7934 | _fnDrawHead( settings, settings.aoFooter ); |
| 7935 | |
| 7936 | // Automatically adjust column sizing |
| 7937 | _fnAdjustColumnSizing( settings ); |
| 7938 | |
| 7939 | // Realign columns for scrolling |
| 7940 | if ( settings.oScroll.sX || settings.oScroll.sY ) { |
| 7941 | _fnScrollDraw( settings ); |
| 7942 | } |
| 7943 | |
| 7944 | _fnCallbackFire( settings, null, 'column-visibility', [settings, column, vis] ); |
no test coverage detected