ColReorder: prevent dragging any column before first column (even if first column hidden)

ColReorder: prevent dragging any column before first column (even if first column hidden)

maartenmachielsmaartenmachiels Posts: 13Questions: 0Answers: 0
edited February 2014 in DataTables 1.9
Hello Allan

I've been tinkering with ColReorder for my client: wonderful!

However, I'm seeing some small problems. My first column always contains the ID of the row record for use with some custom functionality I've implemented (access record on doubleclick, multiple options on single click...). I'm using ColVis, and the first column (ID) is hidden by default.

Now, if I drag a column to the front of my DataTable my custom functionality is broken (because it assumes that the data in the first column is the ID, and now other data is in the first column). That's the first problem. The second problem is that when I reload the page after dragging a column to the front of the table (I'm state saving via localStorage) my table is messed up. Even though the first column header will say for instance "Last Name", the data of the first column is still "ID", now visible.

My question is as follows: would it be possible to prevent dragging any column to precede the first (ID) column, even if this column is hidden?

I'd be glad to PM you a link and login details of my testcase, but I cannot post it here openly since it contains some sensitive data.
Could you please shed some light on this? Thank you thank you kindly!!

Replies

  • maartenmachielsmaartenmachiels Posts: 13Questions: 0Answers: 0
    Hi Allan

    After some investigation, I've figured out how to fix the first column. If I set iFixedColumns to 1 it seems to fix the problem:

    [code]
    "oColReorder": {
    "iFixedColumns": 1
    }
    [/code]

    However, upon reloading the page, statesaving seems to have troubles... The headers are in the correct order, but the data is not.

    What do I do?
  • allanallan Posts: 63,494Questions: 1Answers: 10,470 Site admin
    Which versions of DataTables, ColVis and ColReorder are you using? If not the latest versions, then I'd suggest using the latest versions.

    Allan
  • maartenmachielsmaartenmachiels Posts: 13Questions: 0Answers: 0
    Hi Allan. They are all the latest versions. No beta.
  • maartenmachielsmaartenmachiels Posts: 13Questions: 0Answers: 0
    Woops, I see that I don't have the latest version of ColVis. I will implement it shortly and get back to you. Thanks for your suggestions.
  • maartenmachielsmaartenmachiels Posts: 13Questions: 0Answers: 0
    Hi Allan

    I've now updated ColVis, I was running 1.1.0-dev, and have now updated to 1.1.0. The problem persists... I can reorder rows, but upon reloading the page the headers are in the correct order. The data itself is not.

    My DataTable is populated via Ajax. Could the problem be in there?
  • allanallan Posts: 63,494Questions: 1Answers: 10,470 Site admin
    No - there should be no problem there.

    Can you link me to a test case showing the problem so I can debug it please?

    Allan
  • maartenmachielsmaartenmachiels Posts: 13Questions: 0Answers: 0
    Hi Allan, thank you for your answer. The link is in your inbox. If you cannot find it, let me know, I'll send it again!
This discussion has been closed.