1
1
/*
2
2
* File: ColVis.js
3
- * Version: 1.0.7
3
+ * Version: 1.0.8
4
4
* CVS: $Id$
5
5
* Description: Controls for column visiblity in DataTables
6
6
* Author: Allan Jardine (www.sprymedia.co.uk)
@@ -313,6 +313,7 @@ ColVis.prototype = {
313
313
this . _fnApplyCustomisation ( ) ;
314
314
315
315
var that = this ;
316
+ var i , iLen ;
316
317
this . dom . wrapper = document . createElement ( 'div' ) ;
317
318
this . dom . wrapper . className = "ColVis TableTools" ;
318
319
@@ -327,7 +328,7 @@ ColVis.prototype = {
327
328
this . _fnAddButtons ( ) ;
328
329
329
330
/* Store the original visbility information */
330
- for ( var i = 0 , iLen = this . s . dt . aoColumns . length ; i < iLen ; i ++ )
331
+ for ( i = 0 , iLen = this . s . dt . aoColumns . length ; i < iLen ; i ++ )
331
332
{
332
333
this . s . abOriginal . push ( this . s . dt . aoColumns [ i ] . bVisible ) ;
333
334
}
@@ -339,6 +340,20 @@ ColVis.prototype = {
339
340
} ,
340
341
"sName" : "ColVis"
341
342
} ) ;
343
+
344
+ /* If columns are reordered, then we need to update our exclude list and
345
+ * rebuild the displayed list
346
+ */
347
+ $ ( this . s . dt . oInstance ) . bind ( 'column-reorder' , function ( e , oSettings , oReorder ) {
348
+ for ( i = 0 , iLen = that . s . aiExclude . length ; i < iLen ; i ++ ) {
349
+ that . s . aiExclude [ i ] = oReorder . aiInvertMapping [ that . s . aiExclude [ i ] ] ;
350
+ }
351
+
352
+ var mStore = that . s . abOriginal . splice ( oReorder . iFrom , 1 ) [ 0 ] ;
353
+ that . s . abOriginal . splice ( oReorder . iTo , 0 , mStore ) ;
354
+
355
+ that . fnRebuild ( ) ;
356
+ } ) ;
342
357
} ,
343
358
344
359
@@ -420,8 +435,8 @@ ColVis.prototype = {
420
435
421
436
422
437
/**
423
- * On each table draw, check the visiblity checkboxes as needed. This allows any process to
424
- * update the table's column visiblity and ColVis will still be accurate.
438
+ * On each table draw, check the visibility checkboxes as needed. This allows any process to
439
+ * update the table's column visibility and ColVis will still be accurate.
425
440
* @method _fnDrawCallback
426
441
* @returns void
427
442
* @private
@@ -515,6 +530,7 @@ ColVis.prototype = {
515
530
that . s . dt . oInstance . fnSetColumnVis ( i , that . s . abOriginal [ i ] , false ) ;
516
531
}
517
532
that . _fnAdjustOpenRows ( ) ;
533
+ that . s . dt . oInstance . fnAdjustColumnSizing ( false ) ;
518
534
that . s . dt . oInstance . fnDraw ( false ) ;
519
535
} ) ;
520
536
@@ -549,6 +565,7 @@ ColVis.prototype = {
549
565
}
550
566
}
551
567
that . _fnAdjustOpenRows ( ) ;
568
+ that . s . dt . oInstance . fnAdjustColumnSizing ( false ) ;
552
569
that . s . dt . oInstance . fnDraw ( false ) ;
553
570
} ) ;
554
571
@@ -597,6 +614,7 @@ ColVis.prototype = {
597
614
if ( dt . oFeatures . bServerSide && ( dt . oScroll . sX !== "" || dt . oScroll . sY !== "" ) )
598
615
{
599
616
that . s . dt . oInstance . fnSetColumnVis ( i , showHide , false ) ;
617
+ that . s . dt . oInstance . fnAdjustColumnSizing ( false ) ;
600
618
that . s . dt . oInstance . oApi . _fnScrollDraw ( that . s . dt ) ;
601
619
that . _fnDrawCallback ( ) ;
602
620
}
@@ -923,7 +941,7 @@ ColVis.fnRebuild = function ( oTable )
923
941
924
942
925
943
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
926
- * Static object propterties
944
+ * Static object properties
927
945
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
928
946
929
947
/**
@@ -958,7 +976,7 @@ ColVis.prototype.CLASS = "ColVis";
958
976
* @type String
959
977
* @default See code
960
978
*/
961
- ColVis . VERSION = "1.0.7 " ;
979
+ ColVis . VERSION = "1.0.8 " ;
962
980
ColVis . prototype . VERSION = ColVis . VERSION ;
963
981
964
982
0 commit comments