ColReorder exclude right-most column

ColReorder exclude right-most column

kaseykrehbielkaseykrehbiel Posts: 18Questions: 2Answers: 0
edited November 2012 in General
Does anyone have an implementation of this? The right-most column of my table is a Manage column with buttons in the fields and I don't want it to be Column-reorderable. Thanks for any help!

Replies

  • kaseykrehbielkaseykrehbiel Posts: 18Questions: 2Answers: 0
    edited November 2012
    Okay, I just implemented it myself.

    Changes to the colReorder.js code:

    Added (to the namespace settings object):
    [code]
    /**
    * Number of columns to fix (not allow to be reordered)
    * @property fixedrtl
    * @type int
    * @default 0
    */
    "fixedrtl": 0,
    [/code]

    Added (to _fnConstruct):
    [code]
    /* Columns discounted from reordering - counting right to left */
    if ( typeof this.s.init.iFixedColumnsRtl != 'undefined' )
    {
    this.s.fixedrtl = this.s.init.iFixedColumnsRtl;
    }
    [/code]

    Changed this function (find the comment):
    [code]
    /* Add event handlers for the drag and drop, and also mark the original column order */
    for ( i=0, iLen=this.s.dt.aoColumns.length ; i this.s.fixed-1 && i < (this.s.dt.aoColumns.length - this.s.fixedrtl) )
    {
    this._fnMouseListener( i, this.s.dt.aoColumns[i].nTh );
    }

    /* Mark the original column order for later reference */
    this.s.dt.aoColumns[i]._ColReorder_iOrigCol = i;
    }
    [/code]

    Added (to _fnMouseDown):
    [code]
    /* Disallow columns for being reordered by drag and drop, counting right to left */
    if (this.s.fixedrtl !== 0) {
    this.s.aoTargets.splice(this.s.dt.aoColumns.length - this.s.fixed - this.s.fixedrtl + 1, this.s.fixedrtl);
    }
    [/code]

    I'd recommend adding this to the code base, Allen. I've seen requests for it before and I think it'd make the colReorder extra just a bit more versatile. :-)

    EDIT: Found and squashed a bug concerning fixing both left and right columns. Looks like it works great now.
This discussion has been closed.