Skip to content

Commit 5c030ac

Browse files
committed
ColReorder and ColVis updates
1 parent e4bee54 commit 5c030ac

19 files changed

+93
-73
lines changed

js/DataTables/extras/ColReorder/col_filter.html

+5-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@
5858
],
5959
"oLanguage": {
6060
"sSearch": "Search all columns:"
61-
}
61+
},
62+
"bSortCellsTop": true
6263
} );
6364
} );
6465
</script>
@@ -76,7 +77,7 @@ <h1>Preamble</h1>
7677
elements, and finally of course the filtering itself. Note that it is important to use
7778
the _fnVisibleToColumnIndex() internal function to calculate which column index should
7879
be given to fnFilter (or you could employ your own methods).</p>
79-
<p>Please note that this demo requires DataTables 1.7.5 or later.</p>
80+
<p>Please note that this demo requires DataTables 1.8 or later.</p>
8081

8182
<h1>Live example</h1>
8283
<form>
@@ -572,7 +573,8 @@ <h1>Initialisation code</h1>
572573
],
573574
"oLanguage": {
574575
"sSearch": "Search all columns:"
575-
}
576+
},
577+
"bSortCellsTop": true
576578
} );
577579
} );</pre>
578580

js/DataTables/extras/ColReorder/media/docs/46848f6f3b.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ <h2>Navigation</h2>
6868

6969

7070
Documentation generated by <a href="https://github.com/micmath/JSDoc">JSDoc 3</a> on
71-
15th Apr 2012 - 19:31
71+
21th Jun 2012 - 16:43
7272
with the <a href="http://datatables.net/">DataTables</a> template.
7373
</div>
7474
</body>

js/DataTables/extras/ColReorder/media/docs/4f1246032c.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ <h2>Navigation</h2>
6868

6969

7070
Documentation generated by <a href="https://github.com/micmath/JSDoc">JSDoc 3</a> on
71-
15th Apr 2012 - 19:31
71+
21th Jun 2012 - 16:43
7272
with the <a href="http://datatables.net/">DataTables</a> template.
7373
</div>
7474
</body>

js/DataTables/extras/ColReorder/media/docs/ColReorder.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ <h5>Parameters:</h5>
139139

140140

141141
Documentation generated by <a href="https://github.com/micmath/JSDoc">JSDoc 3</a> on
142-
15th Apr 2012 - 19:31
142+
21th Jun 2012 - 16:43
143143
with the <a href="http://datatables.net/">DataTables</a> template.
144144
</div>
145145
</body>

js/DataTables/extras/ColReorder/media/docs/a69b02bcf2.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ <h2>Navigation</h2>
6868

6969

7070
Documentation generated by <a href="https://github.com/micmath/JSDoc">JSDoc 3</a> on
71-
15th Apr 2012 - 19:31
71+
21th Jun 2012 - 16:43
7272
with the <a href="http://datatables.net/">DataTables</a> template.
7373
</div>
7474
</body>

js/DataTables/extras/ColReorder/media/docs/global.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ <h5>Parameters:</h5>
170170

171171

172172
Documentation generated by <a href="https://github.com/micmath/JSDoc">JSDoc 3</a> on
173-
15th Apr 2012 - 19:31
173+
21th Jun 2012 - 16:43
174174
with the <a href="http://datatables.net/">DataTables</a> template.
175175
</div>
176176
</body>

js/DataTables/extras/ColReorder/media/docs/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ <h3 class="subsection-title">Table of Contents</h3>
3333

3434

3535
Documentation generated by <a href="https://github.com/micmath/JSDoc">JSDoc 3</a> on
36-
15th Apr 2012 - 19:31
36+
21th Jun 2012 - 16:43
3737
with the <a href="http://datatables.net/">DataTables</a> template.
3838
</div>
3939
</body>

js/DataTables/extras/ColReorder/media/js/ColReorder.js

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* File: ColReorder.js
3-
* Version: 1.0.5
3+
* Version: 1.0.6
44
* CVS: $Id$
55
* Description: Controls for column visiblity in DataTables
66
* Author: Allan Jardine (www.sprymedia.co.uk)
@@ -274,13 +274,12 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
274274
}
275275

276276

277-
/*
278-
* Any extra operations for the other plug-ins
279-
*/
280-
if ( typeof ColVis != 'undefined' )
281-
{
282-
ColVis.fnRebuild( oSettings.oInstance );
283-
}
277+
/* Fire an event so other plug-ins can update */
278+
$(oSettings.oInstance).trigger( 'column-reorder', [ oSettings, {
279+
"iFrom": iFrom,
280+
"iTo": iTo,
281+
"aiInvertMapping": aiInvertMapping
282+
} ] );
284283

285284
if ( typeof oSettings.oInstance._oPluginFixedHeader != 'undefined' )
286285
{
@@ -527,7 +526,7 @@ ColReorder.prototype = {
527526
{
528527
if ( a.length != this.s.dt.aoColumns.length )
529528
{
530-
this.s.dt.oInstance.oApi._fnLog( oDTSettings, 1, "ColReorder - array reorder does not "+
529+
this.s.dt.oInstance.oApi._fnLog( this.s.dt, 1, "ColReorder - array reorder does not "+
531530
"match known number of columns. Skipping." );
532531
return;
533532
}
@@ -611,8 +610,8 @@ ColReorder.prototype = {
611610
{
612611
var that = this;
613612
$(nTh).bind( 'mousedown.ColReorder', function (e) {
613+
e.preventDefault();
614614
that._fnMouseDown.call( that, e, nTh );
615-
return false;
616615
} );
617616
},
618617

@@ -914,7 +913,7 @@ ColReorder.prototype.CLASS = "ColReorder";
914913
* @type String
915914
* @default As code
916915
*/
917-
ColReorder.VERSION = "1.0.5";
916+
ColReorder.VERSION = "1.0.6";
918917
ColReorder.prototype.VERSION = ColReorder.VERSION;
919918

920919

js/DataTables/extras/ColReorder/media/js/ColReorder.min.js

+21-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

js/DataTables/extras/ColReorder/theme.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ <h1>Examples</h1>
484484
<h1>Initialisation code</h1>
485485
<pre>$(document).ready( function () {
486486
var oTable = $('#example').dataTable( {
487-
"sDom": 'R&lt;"H"lfr&gt;t&lt;"F"ip&lt;',
487+
"sDom": 'R&lt;"H"lfr&gt;t&lt;"F"ip&gt;',
488488
"bJQueryUI": true,
489489
"sPaginationType": "full_numbers"
490490
} );

js/DataTables/extras/ColVis/media/docs/ColVis.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ <h5>Parameters:</h5>
143143

144144

145145
Documentation generated by <a href="https://github.com/micmath/JSDoc">JSDoc 3</a> on
146-
15th Apr 2012 - 19:30
146+
21th Jun 2012 - 16:43
147147
with the <a href="http://datatables.net/">DataTables</a> template.
148148
</div>
149149
</body>

js/DataTables/extras/ColVis/media/docs/a69b02bcf2.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ <h2>Navigation</h2>
6868

6969

7070
Documentation generated by <a href="https://github.com/micmath/JSDoc">JSDoc 3</a> on
71-
15th Apr 2012 - 19:30
71+
21th Jun 2012 - 16:43
7272
with the <a href="http://datatables.net/">DataTables</a> template.
7373
</div>
7474
</body>

js/DataTables/extras/ColVis/media/docs/ccb5a49865.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ <h2>Navigation</h2>
6868

6969

7070
Documentation generated by <a href="https://github.com/micmath/JSDoc">JSDoc 3</a> on
71-
15th Apr 2012 - 19:30
71+
21th Jun 2012 - 16:43
7272
with the <a href="http://datatables.net/">DataTables</a> template.
7373
</div>
7474
</body>

js/DataTables/extras/ColVis/media/docs/global.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ <h5>Returns:</h5><p class="returns">void</p></div>
107107

108108

109109
Documentation generated by <a href="https://github.com/micmath/JSDoc">JSDoc 3</a> on
110-
15th Apr 2012 - 19:30
110+
21th Jun 2012 - 16:43
111111
with the <a href="http://datatables.net/">DataTables</a> template.
112112
</div>
113113
</body>

js/DataTables/extras/ColVis/media/docs/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ <h3 class="subsection-title">Table of Contents</h3>
3333

3434

3535
Documentation generated by <a href="https://github.com/micmath/JSDoc">JSDoc 3</a> on
36-
15th Apr 2012 - 19:30
36+
21th Jun 2012 - 16:43
3737
with the <a href="http://datatables.net/">DataTables</a> template.
3838
</div>
3939
</body>

js/DataTables/extras/ColVis/media/js/ColVis.js

+24-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* File: ColVis.js
3-
* Version: 1.0.7
3+
* Version: 1.0.8
44
* CVS: $Id$
55
* Description: Controls for column visiblity in DataTables
66
* Author: Allan Jardine (www.sprymedia.co.uk)
@@ -313,6 +313,7 @@ ColVis.prototype = {
313313
this._fnApplyCustomisation();
314314

315315
var that = this;
316+
var i, iLen;
316317
this.dom.wrapper = document.createElement('div');
317318
this.dom.wrapper.className = "ColVis TableTools";
318319

@@ -327,7 +328,7 @@ ColVis.prototype = {
327328
this._fnAddButtons();
328329

329330
/* 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++ )
331332
{
332333
this.s.abOriginal.push( this.s.dt.aoColumns[i].bVisible );
333334
}
@@ -339,6 +340,20 @@ ColVis.prototype = {
339340
},
340341
"sName": "ColVis"
341342
} );
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+
} );
342357
},
343358

344359

@@ -420,8 +435,8 @@ ColVis.prototype = {
420435

421436

422437
/**
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.
425440
* @method _fnDrawCallback
426441
* @returns void
427442
* @private
@@ -515,6 +530,7 @@ ColVis.prototype = {
515530
that.s.dt.oInstance.fnSetColumnVis( i, that.s.abOriginal[i], false );
516531
}
517532
that._fnAdjustOpenRows();
533+
that.s.dt.oInstance.fnAdjustColumnSizing( false );
518534
that.s.dt.oInstance.fnDraw( false );
519535
} );
520536

@@ -549,6 +565,7 @@ ColVis.prototype = {
549565
}
550566
}
551567
that._fnAdjustOpenRows();
568+
that.s.dt.oInstance.fnAdjustColumnSizing( false );
552569
that.s.dt.oInstance.fnDraw( false );
553570
} );
554571

@@ -597,6 +614,7 @@ ColVis.prototype = {
597614
if ( dt.oFeatures.bServerSide && (dt.oScroll.sX !== "" || dt.oScroll.sY !== "" ) )
598615
{
599616
that.s.dt.oInstance.fnSetColumnVis( i, showHide, false );
617+
that.s.dt.oInstance.fnAdjustColumnSizing( false );
600618
that.s.dt.oInstance.oApi._fnScrollDraw( that.s.dt );
601619
that._fnDrawCallback();
602620
}
@@ -923,7 +941,7 @@ ColVis.fnRebuild = function ( oTable )
923941

924942

925943
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
926-
* Static object propterties
944+
* Static object properties
927945
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
928946

929947
/**
@@ -958,7 +976,7 @@ ColVis.prototype.CLASS = "ColVis";
958976
* @type String
959977
* @default See code
960978
*/
961-
ColVis.VERSION = "1.0.7";
979+
ColVis.VERSION = "1.0.8";
962980
ColVis.prototype.VERSION = ColVis.VERSION;
963981

964982

0 commit comments

Comments
 (0)