ColReorder + FixedColumns plugin

ColReorder + FixedColumns plugin

jrevaijrevai Posts: 6Questions: 0Answers: 0
edited May 2012 in Plug-ins
Hi,

I just started using Datatables.js. I have a requirement to be able to use ColReorder + FixedColumns plugins on the same table. The bug I think I've found:
- Create a datatable, my datatable has 8 columns but column count doesn't mather
- use ColumnsPlugin plugin, set the first two columns to fixed
...
"oColReorder": {
"iFixedColumns": 2
}
...
- use FixedColumns plugin, set iLeftColumns to 2
....
new FixedColumns(oTable, {
"iLeftColumns": 2,
"iLeftWidth": 264
})
....

Now if you start dragging column header:
- you cannot drag the first two columns that are fixed by the FixedColumns plugin - ok
- you cannot drag elements before/between the first two columns that are fixed by the FixedColumn plugin - ok
- you can drag the first two columns that are NOT fixed by the FixedColumns plugin - ok
Issue: you cannot drag elements to before/between the first two columns NOT fixed by the FixedColumns plugin. For example, if you would like to move the third column NOT fixed by the FixedColumns plugin to between the first and second column, you can't.
You can reproduce this bug on the demo site too:
http://datatables.net/release-datatables/extras/ColReorder/fixedcolumns.html
You cannot move the Browser column to between the index column and the Rendering engine column.

I think the problem is, that there should be to numbers: iFixedColumns: how many columns cannot be moved counted from the left.
iFixedByFixedColumnsPlugin.
...
"oColReorder": {
"iFixedColumns": 2
"iFixedByTheFixedColumnsPlugin": 2
}
...

ColReorder _fnMouseDown:

aoTargets array does not contain the columns that are fixed by the FixedColumns plugin, so those columns shouldn't be spliced.
/* Disallow columns for being reordered by drag and drop, counting left to right */
if (this.s.fixed !== 0)
{
this.s.aoTargets.splice( 0, this.s.fixed - this.s.fixedByFixedColumnsPlugin );
}

ColReorder _fnMouseMove:
when calculating this.s.mouse.toIndex is calculated based on the non fixed table indexes, to make the fnArraySwitch function work properly with, the toIndex should be added up by the this.s.fixedByFixedColumnsPlugin number:

"_fnMouseMove": function ( e )
{
.....

/* Based on the current mouse position, calculate where the insert should go */
var bSet = false;
for ( var i=1, iLen=this.s.aoTargets.length ; i

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Yup - most certainly a bug! Thanks for your investigation into it. I'll look at your suggestion a bit more closely and commit it in soon. I'll post back here when done :-)

    Allan
  • jrevaijrevai Posts: 6Questions: 0Answers: 0
    In _fnMouseMove instead of

    this.s.mouse.toIndex = this.s.aoTargets[this.s.aoTargets.length-1].to + this.s.fixedBFixedColumnsPlugin;

    This is the right one:

    if (this.s.mouse.toIndex < this.s.fixedByFixedColumnsPlugin) {
    this.s.mouse.toIndex += this.s.fixedByFixedColumnsPlugin;
    }
  • kaiserkaiser Posts: 1Questions: 0Answers: 0
    Hi Allen,

    did you ever come back to this issue?

    Alex
  • blinkjonblinkjon Posts: 2Questions: 0Answers: 0
    Allan,

    I just downloaded version 1.0.8 and the bug is still present. Is there any fix to it available in a newer version?

    -Jon
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Try the nightly from the downloads page please.

    Allan
  • shashidharshashidhar Posts: 1Questions: 0Answers: 0
    Hi Allen,

    I am looking for a Table widget that can do the fixed column, column reordering, right scroll and also automatically pagination when you scroll down.

    Thank you
    Shashi
This discussion has been closed.