5 * Description: Allow columns to be reordered in a DataTable
6 * Author: Allan Jardine (www.sprymedia.co.uk)
7 * Created: Wed Sep 15 18:23:29 BST 2010
8 * Modified: $Date$ by $Author$
10 * License: GPL v2 or BSD 3 point style
12 * Contact: www.sprymedia.co.uk/contact
14 * Copyright 2010-2011 Allan Jardine, all rights reserved.
16 * This source file is free software, under either the GPL v2 license or a
17 * BSD style license, available at:
18 * http://datatables.net/license_gpl2
19 * http://datatables.net/license_bsd
24 (function($, window, document) {
28 * Switch the key value pairing of an index array to be value key (i.e. the old value is now the
29 * key). For example consider [ 2, 0, 1 ] this would be returned as [ 1, 2, 0 ].
30 * @method fnInvertKeyValues
31 * @param array aIn Array to switch around
34 function fnInvertKeyValues( aIn )
37 for ( var i=0, iLen=aIn.length ; i<iLen ; i++ )
46 * Modify an array by switching the position of two elements
47 * @method fnArraySwitch
48 * @param array aArray Array to consider, will be modified by reference (i.e. no return)
49 * @param int iFrom From point
50 * @param int iTo Insert point
53 function fnArraySwitch( aArray, iFrom, iTo )
55 var mStore = aArray.splice( iFrom, 1 )[0];
56 aArray.splice( iTo, 0, mStore );
61 * Switch the positions of nodes in a parent node (note this is specifically designed for
62 * table rows). Note this function considers all element nodes under the parent!
64 * @param string sTag Tag to consider
65 * @param int iFrom Element to move
66 * @param int Point to element the element to (before this point), can be null for append
69 function fnDomSwitch( nParent, iFrom, iTo )
72 for ( var i=0, iLen=nParent.childNodes.length ; i<iLen ; i++ )
74 if ( nParent.childNodes[i].nodeType == 1 )
76 anTags.push( nParent.childNodes[i] );
79 var nStore = anTags[ iFrom ];
83 nParent.insertBefore( nStore, anTags[iTo] );
87 nParent.appendChild( nStore );
93 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
94 * DataTables plug-in API functions
96 * This are required by ColReorder in order to perform the tasks required, and also keep this
97 * code portable, to be used for other column reordering projects with DataTables, if needed.
98 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
102 * Plug-in for DataTables which will reorder the internal column structure by taking the column
103 * from one position (iFrom) and insert it into a given point (iTo).
104 * @method $.fn.dataTableExt.oApi.fnColReorder
105 * @param object oSettings DataTables settings object - automatically added by DataTables!
106 * @param int iFrom Take the column to be repositioned from this point
107 * @param int iTo and insert it into this point
110 $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
112 var i, iLen, j, jLen, iCols=oSettings.aoColumns.length, nTrs, oCol;
114 /* Sanity check in the input */
117 /* Pointless reorder */
121 if ( iFrom < 0 || iFrom >= iCols )
123 this.oApi._fnLog( oSettings, 1, "ColReorder 'from' index is out of bounds: "+iFrom );
127 if ( iTo < 0 || iTo >= iCols )
129 this.oApi._fnLog( oSettings, 1, "ColReorder 'to' index is out of bounds: "+iTo );
134 * Calculate the new column array index, so we have a mapping between the old and new
137 for ( i=0, iLen=iCols ; i<iLen ; i++ )
141 fnArraySwitch( aiMapping, iFrom, iTo );
142 var aiInvertMapping = fnInvertKeyValues( aiMapping );
146 * Convert all internal indexing to the new column order indexes
149 for ( i=0, iLen=oSettings.aaSorting.length ; i<iLen ; i++ )
151 oSettings.aaSorting[i][0] = aiInvertMapping[ oSettings.aaSorting[i][0] ];
155 if ( oSettings.aaSortingFixed !== null )
157 for ( i=0, iLen=oSettings.aaSortingFixed.length ; i<iLen ; i++ )
159 oSettings.aaSortingFixed[i][0] = aiInvertMapping[ oSettings.aaSortingFixed[i][0] ];
163 /* Data column sorting (the column which the sort for a given column should take place on) */
164 for ( i=0, iLen=iCols ; i<iLen ; i++ )
166 oCol = oSettings.aoColumns[i];
167 for ( j=0, jLen=oCol.aDataSort.length ; j<jLen ; j++ )
169 oCol.aDataSort[j] = aiInvertMapping[ oCol.aDataSort[j] ];
173 /* Update the Get and Set functions for each column */
174 for ( i=0, iLen=iCols ; i<iLen ; i++ )
176 oCol = oSettings.aoColumns[i];
177 if ( typeof oCol.mData == 'number' ) {
178 oCol.mData = aiInvertMapping[ oCol.mData ];
179 oCol.fnGetData = oSettings.oApi._fnGetObjectDataFn( oCol.mData );
180 oCol.fnSetData = oSettings.oApi._fnSetObjectDataFn( oCol.mData );
186 * Move the DOM elements
188 if ( oSettings.aoColumns[iFrom].bVisible )
190 /* Calculate the current visible index and the point to insert the node before. The insert
191 * before needs to take into account that there might not be an element to insert before,
192 * in which case it will be null, and an appendChild should be used
194 var iVisibleIndex = this.oApi._fnColumnIndexToVisible( oSettings, iFrom );
195 var iInsertBeforeIndex = null;
197 i = iTo < iFrom ? iTo : iTo + 1;
198 while ( iInsertBeforeIndex === null && i < iCols )
200 iInsertBeforeIndex = this.oApi._fnColumnIndexToVisible( oSettings, i );
205 nTrs = oSettings.nTHead.getElementsByTagName('tr');
206 for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
208 fnDomSwitch( nTrs[i], iVisibleIndex, iInsertBeforeIndex );
212 if ( oSettings.nTFoot !== null )
214 nTrs = oSettings.nTFoot.getElementsByTagName('tr');
215 for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
217 fnDomSwitch( nTrs[i], iVisibleIndex, iInsertBeforeIndex );
222 for ( i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
224 if ( oSettings.aoData[i].nTr !== null )
226 fnDomSwitch( oSettings.aoData[i].nTr, iVisibleIndex, iInsertBeforeIndex );
233 * Move the internal array elements
236 fnArraySwitch( oSettings.aoColumns, iFrom, iTo );
239 fnArraySwitch( oSettings.aoPreSearchCols, iFrom, iTo );
241 /* Array array - internal data anodes cache */
242 for ( i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
244 if ( $.isArray( oSettings.aoData[i]._aData ) ) {
245 fnArraySwitch( oSettings.aoData[i]._aData, iFrom, iTo );
247 fnArraySwitch( oSettings.aoData[i]._anHidden, iFrom, iTo );
250 /* Reposition the header elements in the header layout array */
251 for ( i=0, iLen=oSettings.aoHeader.length ; i<iLen ; i++ )
253 fnArraySwitch( oSettings.aoHeader[i], iFrom, iTo );
256 if ( oSettings.aoFooter !== null )
258 for ( i=0, iLen=oSettings.aoFooter.length ; i<iLen ; i++ )
260 fnArraySwitch( oSettings.aoFooter[i], iFrom, iTo );
266 * Update DataTables' event handlers
270 for ( i=0, iLen=iCols ; i<iLen ; i++ )
272 $(oSettings.aoColumns[i].nTh).unbind('click');
273 this.oApi._fnSortAttachListener( oSettings, oSettings.aoColumns[i].nTh, i );
277 /* Fire an event so other plug-ins can update */
278 $(oSettings.oInstance).trigger( 'column-reorder', [ oSettings, {
281 "aiInvertMapping": aiInvertMapping
284 if ( typeof oSettings.oInstance._oPluginFixedHeader != 'undefined' )
286 oSettings.oInstance._oPluginFixedHeader.fnUpdate();
294 * ColReorder provides column visiblity control for DataTables
297 * @param {object} DataTables settings object
298 * @param {object} ColReorder options
300 ColReorder = function( oDTSettings, oOpts )
302 /* Santiy check that we are a new instance */
303 if ( !this.CLASS || this.CLASS != "ColReorder" )
305 alert( "Warning: ColReorder must be initialised with the keyword 'new'" );
308 if ( typeof oOpts == 'undefined' )
314 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
315 * Public class variables
316 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
319 * @namespace Settings object which contains customisable information for ColReorder instance
323 * DataTables settings object
331 * Initialisation object used for this instance
339 * Number of columns to fix (not allow to be reordered)
347 * Callback function for once the reorder has been done
348 * @property dropcallback
352 "dropCallback": null,
355 * @namespace Information used for the mouse drag
368 * Information which is used for positioning the insert cusor and knowing where to do the
369 * insert. Array of objects with the properties:
372 * @property aoTargets
381 * @namespace Common and useful DOM elements for the class instance
385 * Dragging element (the one the mouse is moving)
402 /* Constructor logic */
403 this.s.dt = oDTSettings.oInstance.fnSettings();
406 /* Add destroy callback */
407 oDTSettings.oApi._fnCallbackReg(oDTSettings, 'aoDestroyCallback', jQuery.proxy(this._fnDestroy, this), 'ColReorder');
409 /* Store the instance for later use */
410 ColReorder.aoInstances.push( this );
416 ColReorder.prototype = {
417 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
419 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
421 "fnReset": function ()
424 for ( var i=0, iLen=this.s.dt.aoColumns.length ; i<iLen ; i++ )
426 a.push( this.s.dt.aoColumns[i]._ColReorder_iOrigCol );
429 this._fnOrderColumns( a );
433 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
434 * Private methods (they are of course public in JS, but recommended as private)
435 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
439 * @method _fnConstruct
443 "_fnConstruct": function ()
448 /* Columns discounted from reordering - counting left to right */
449 if ( typeof this.s.init.iFixedColumns != 'undefined' )
451 this.s.fixed = this.s.init.iFixedColumns;
454 /* Drop callback initialisation option */
455 if ( typeof this.s.init.fnReorderCallback != 'undefined' )
457 this.s.dropCallback = this.s.init.fnReorderCallback;
460 /* Add event handlers for the drag and drop, and also mark the original column order */
461 for ( i=0, iLen=this.s.dt.aoColumns.length ; i<iLen ; i++ )
463 if ( i > this.s.fixed-1 )
465 this._fnMouseListener( i, this.s.dt.aoColumns[i].nTh );
468 /* Mark the original column order for later reference */
469 this.s.dt.aoColumns[i]._ColReorder_iOrigCol = i;
473 this.s.dt.oApi._fnCallbackReg( this.s.dt, 'aoStateSaveParams', function (oS, oData) {
474 that._fnStateSave.call( that, oData );
475 }, "ColReorder_State" );
477 /* An initial column order has been specified */
479 if ( typeof this.s.init.aiOrder != 'undefined' )
481 aiOrder = this.s.init.aiOrder.slice();
484 /* State loading, overrides the column order given */
485 if ( this.s.dt.oLoadedState && typeof this.s.dt.oLoadedState.ColReorder != 'undefined' &&
486 this.s.dt.oLoadedState.ColReorder.length == this.s.dt.aoColumns.length )
488 aiOrder = this.s.dt.oLoadedState.ColReorder;
491 /* If we have an order to apply - do so */
494 /* We might be called during or after the DataTables initialisation. If before, then we need
495 * to wait until the draw is done, if after, then do what we need to do right away
497 if ( !that.s.dt._bInitComplete )
500 this.s.dt.aoDrawCallback.push( {
502 if ( !that.s.dt._bInitComplete && !bDone )
505 var resort = fnInvertKeyValues( aiOrder );
506 that._fnOrderColumns.call( that, resort );
509 "sName": "ColReorder_Pre"
514 var resort = fnInvertKeyValues( aiOrder );
515 that._fnOrderColumns.call( that, resort );
522 * Set the column order from an array
523 * @method _fnOrderColumns
524 * @param array a An array of integers which dictate the column order that should be applied
528 "_fnOrderColumns": function ( a )
530 if ( a.length != this.s.dt.aoColumns.length )
532 this.s.dt.oInstance.oApi._fnLog( this.s.dt, 1, "ColReorder - array reorder does not "+
533 "match known number of columns. Skipping." );
537 for ( var i=0, iLen=a.length ; i<iLen ; i++ )
539 var currIndex = $.inArray( i, a );
540 if ( i != currIndex )
542 /* Reorder our switching array */
543 fnArraySwitch( a, currIndex, i );
545 /* Do the column reorder in the table */
546 this.s.dt.oInstance.fnColReorder( currIndex, i );
550 /* When scrolling we need to recalculate the column sizes to allow for the shift */
551 if ( this.s.dt.oScroll.sX !== "" || this.s.dt.oScroll.sY !== "" )
553 this.s.dt.oInstance.fnAdjustColumnSizing();
557 this.s.dt.oInstance.oApi._fnSaveState( this.s.dt );
562 * Because we change the indexes of columns in the table, relative to their starting point
563 * we need to reorder the state columns to what they are at the starting point so we can
564 * then rearrange them again on state load!
565 * @method _fnStateSave
566 * @param object oState DataTables state
567 * @returns string JSON encoded cookie string for DataTables
570 "_fnStateSave": function ( oState )
572 var i, iLen, aCopy, iOrigColumn;
573 var oSettings = this.s.dt;
576 for ( i=0 ; i<oState.aaSorting.length ; i++ )
578 oState.aaSorting[i][0] = oSettings.aoColumns[ oState.aaSorting[i][0] ]._ColReorder_iOrigCol;
581 aSearchCopy = $.extend( true, [], oState.aoSearchCols );
582 oState.ColReorder = [];
584 for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
586 iOrigColumn = oSettings.aoColumns[i]._ColReorder_iOrigCol;
589 oState.aoSearchCols[ iOrigColumn ] = aSearchCopy[i];
592 oState.abVisCols[ iOrigColumn ] = oSettings.aoColumns[i].bVisible;
594 /* Column reordering */
595 oState.ColReorder.push( iOrigColumn );
600 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
601 * Mouse drop and drag
605 * Add a mouse down listener to a particluar TH element
606 * @method _fnMouseListener
607 * @param int i Column index
608 * @param element nTh TH element clicked on
612 "_fnMouseListener": function ( i, nTh )
615 $(nTh).bind( 'mousedown.ColReorder', function (e) {
617 that._fnMouseDown.call( that, e, nTh );
623 * Mouse down on a TH element in the table header
624 * @method _fnMouseDown
625 * @param event e Mouse event
626 * @param element nTh TH element to be dragged
630 "_fnMouseDown": function ( e, nTh )
634 aoColumns = this.s.dt.aoColumns;
636 /* Store information about the mouse position */
637 var nThTarget = e.target.nodeName == "TH" ? e.target : $(e.target).parents('TH')[0];
638 var offset = $(nThTarget).offset();
639 this.s.mouse.startX = e.pageX;
640 this.s.mouse.startY = e.pageY;
641 this.s.mouse.offsetX = e.pageX - offset.left;
642 this.s.mouse.offsetY = e.pageY - offset.top;
643 this.s.mouse.target = nTh;
644 this.s.mouse.targetIndex = $('th', nTh.parentNode).index( nTh );
645 this.s.mouse.fromIndex = this.s.dt.oInstance.oApi._fnVisibleToColumnIndex( this.s.dt,
646 this.s.mouse.targetIndex );
648 /* Calculate a cached array with the points of the column inserts, and the 'to' points */
649 this.s.aoTargets.splice( 0, this.s.aoTargets.length );
651 this.s.aoTargets.push( {
652 "x": $(this.s.dt.nTable).offset().left,
657 for ( var i=0, iLen=aoColumns.length ; i<iLen ; i++ )
659 /* For the column / header in question, we want it's position to remain the same if the
660 * position is just to it's immediate left or right, so we only incremement the counter for
663 if ( i != this.s.mouse.fromIndex )
668 if ( aoColumns[i].bVisible )
670 this.s.aoTargets.push( {
671 "x": $(aoColumns[i].nTh).offset().left + $(aoColumns[i].nTh).outerWidth(),
677 /* Disallow columns for being reordered by drag and drop, counting left to right */
678 if ( this.s.fixed !== 0 )
680 this.s.aoTargets.splice( 0, this.s.fixed );
683 /* Add event handlers to the document */
684 $(document).bind( 'mousemove.ColReorder', function (e) {
685 that._fnMouseMove.call( that, e );
688 $(document).bind( 'mouseup.ColReorder', function (e) {
689 that._fnMouseUp.call( that, e );
695 * Deal with a mouse move event while dragging a node
696 * @method _fnMouseMove
697 * @param event e Mouse event
701 "_fnMouseMove": function ( e )
705 if ( this.dom.drag === null )
707 /* Only create the drag element if the mouse has moved a specific distance from the start
708 * point - this allows the user to make small mouse movements when sorting and not have a
709 * possibly confusing drag element showing up
712 Math.pow(e.pageX - this.s.mouse.startX, 2) +
713 Math.pow(e.pageY - this.s.mouse.startY, 2), 0.5 ) < 5 )
717 this._fnCreateDragNode();
720 /* Position the element - we respect where in the element the click occured */
721 this.dom.drag.style.left = (e.pageX - this.s.mouse.offsetX) + "px";
722 this.dom.drag.style.top = (e.pageY - this.s.mouse.offsetY) + "px";
724 /* Based on the current mouse position, calculate where the insert should go */
726 for ( var i=1, iLen=this.s.aoTargets.length ; i<iLen ; i++ )
728 if ( e.pageX < this.s.aoTargets[i-1].x + ((this.s.aoTargets[i].x-this.s.aoTargets[i-1].x)/2) )
730 this.dom.pointer.style.left = this.s.aoTargets[i-1].x +"px";
731 this.s.mouse.toIndex = this.s.aoTargets[i-1].to;
737 /* The insert element wasn't positioned in the array (less than operator), so we put it at
742 this.dom.pointer.style.left = this.s.aoTargets[this.s.aoTargets.length-1].x +"px";
743 this.s.mouse.toIndex = this.s.aoTargets[this.s.aoTargets.length-1].to;
749 * Finish off the mouse drag and insert the column where needed
751 * @param event e Mouse event
755 "_fnMouseUp": function ( e )
759 $(document).unbind( 'mousemove.ColReorder' );
760 $(document).unbind( 'mouseup.ColReorder' );
762 if ( this.dom.drag !== null )
764 /* Remove the guide elements */
765 document.body.removeChild( this.dom.drag );
766 document.body.removeChild( this.dom.pointer );
767 this.dom.drag = null;
768 this.dom.pointer = null;
770 /* Actually do the reorder */
771 this.s.dt.oInstance.fnColReorder( this.s.mouse.fromIndex, this.s.mouse.toIndex );
773 /* When scrolling we need to recalculate the column sizes to allow for the shift */
774 if ( this.s.dt.oScroll.sX !== "" || this.s.dt.oScroll.sY !== "" )
776 this.s.dt.oInstance.fnAdjustColumnSizing();
779 if ( this.s.dropCallback !== null )
781 this.s.dropCallback.call( this );
785 this.s.dt.oInstance.oApi._fnSaveState( this.s.dt );
791 * Copy the TH element that is being drags so the user has the idea that they are actually
792 * moving it around the page.
793 * @method _fnCreateDragNode
797 "_fnCreateDragNode": function ()
801 this.dom.drag = $(this.s.dt.nTHead.parentNode).clone(true)[0];
802 this.dom.drag.className += " DTCR_clonedTable";
803 while ( this.dom.drag.getElementsByTagName('caption').length > 0 )
805 this.dom.drag.removeChild( this.dom.drag.getElementsByTagName('caption')[0] );
807 while ( this.dom.drag.getElementsByTagName('tbody').length > 0 )
809 this.dom.drag.removeChild( this.dom.drag.getElementsByTagName('tbody')[0] );
811 while ( this.dom.drag.getElementsByTagName('tfoot').length > 0 )
813 this.dom.drag.removeChild( this.dom.drag.getElementsByTagName('tfoot')[0] );
816 $('thead tr:eq(0)', this.dom.drag).each( function () {
817 $('th', this).eq(that.s.mouse.targetIndex).siblings().remove();
819 $('tr', this.dom.drag).height( $('tr:eq(0)', that.s.dt.nTHead).height() );
821 $('thead tr:gt(0)', this.dom.drag).remove();
823 $('thead th:eq(0)', this.dom.drag).each( function (i) {
824 this.style.width = $('th:eq('+that.s.mouse.targetIndex+')', that.s.dt.nTHead).width()+"px";
827 this.dom.drag.style.position = "absolute";
828 this.dom.drag.style.top = "0px";
829 this.dom.drag.style.left = "0px";
830 this.dom.drag.style.width = $('th:eq('+that.s.mouse.targetIndex+')', that.s.dt.nTHead).outerWidth()+"px";
833 this.dom.pointer = document.createElement( 'div' );
834 this.dom.pointer.className = "DTCR_pointer";
835 this.dom.pointer.style.position = "absolute";
837 if ( this.s.dt.oScroll.sX === "" && this.s.dt.oScroll.sY === "" )
839 this.dom.pointer.style.top = $(this.s.dt.nTable).offset().top+"px";
840 this.dom.pointer.style.height = $(this.s.dt.nTable).height()+"px";
844 this.dom.pointer.style.top = $('div.dataTables_scroll', this.s.dt.nTableWrapper).offset().top+"px";
845 this.dom.pointer.style.height = $('div.dataTables_scroll', this.s.dt.nTableWrapper).height()+"px";
848 document.body.appendChild( this.dom.pointer );
849 document.body.appendChild( this.dom.drag );
853 * Clean up ColReorder memory references and event handlers
858 "_fnDestroy": function ()
860 for ( var i=0, iLen=ColReorder.aoInstances.length ; i<iLen ; i++ )
862 if ( ColReorder.aoInstances[i] === this )
864 ColReorder.aoInstances.splice( i, 1 );
869 $(this.s.dt.nTHead).find( '*' ).unbind( '.ColReorder' );
871 this.s.dt.oInstance._oPluginColReorder = null;
880 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
882 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
885 * Array of all ColReorder instances for later reference
886 * @property ColReorder.aoInstances
891 ColReorder.aoInstances = [];
897 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
899 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
902 * Reset the column ordering for a DataTables instance
903 * @method ColReorder.fnReset
904 * @param object oTable DataTables instance to consider
908 ColReorder.fnReset = function ( oTable )
910 for ( var i=0, iLen=ColReorder.aoInstances.length ; i<iLen ; i++ )
912 if ( ColReorder.aoInstances[i].s.dt.oInstance == oTable )
914 ColReorder.aoInstances[i].fnReset();
923 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
925 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
931 * @default ColReorder
933 ColReorder.prototype.CLASS = "ColReorder";
942 ColReorder.VERSION = "1.0.8";
943 ColReorder.prototype.VERSION = ColReorder.VERSION;
949 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
951 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
954 * Register a new feature with DataTables
956 if ( typeof $.fn.dataTable == "function" &&
957 typeof $.fn.dataTableExt.fnVersionCheck == "function" &&
958 $.fn.dataTableExt.fnVersionCheck('1.9.3') )
960 $.fn.dataTableExt.aoFeatures.push( {
961 "fnInit": function( oDTSettings ) {
962 var oTable = oDTSettings.oInstance;
963 if ( typeof oTable._oPluginColReorder == 'undefined' ) {
964 var opts = typeof oDTSettings.oInit.oColReorder != 'undefined' ?
965 oDTSettings.oInit.oColReorder : {};
966 oTable._oPluginColReorder = new ColReorder( oDTSettings, opts );
968 oTable.oApi._fnLog( oDTSettings, 1, "ColReorder attempted to initialise twice. Ignoring second" );
971 return null; /* No node to insert */
974 "sFeature": "ColReorder"
979 alert( "Warning: ColReorder requires DataTables 1.9.3 or greater - www.datatables.net/download");
982 })(jQuery, window, document);