ColReorder enable/disable using api not working

ColReorder enable/disable using api not working

az1az1 Posts: 14Questions: 7Answers: 1
edited May 2018 in Free community support

Have been trying to enable/disable the colreorder functionality but cannot get it to disable.

Want to load our datatable in "view only" mode, so cannot reorder columns. Then pressing an edit button will enable colreorder, and then pressing a save/cancel button will disable colreorder.

Have managed to disable on load by setting "colReorder": false in datatable config.

Then pressing edit button I can call any of the following to enable colreorder:

   var table = $('#dataTableSites').DataTable();
   new $.fn.dataTable.ColReorder(table, { "fixedColumnsLeft": 1 });  // turn re-order on
   new $.fn.dataTable.ColReorder(table, { colReorder: true });  // turn re-order on

but in the cancel/save button click event I have tried all of the following without success:

   var table = $('#dataTableSites').DataTable();

   new $.fn.dataTable.ColReorder(table, {colReorder: false});  // turn re-order off
   new $.fn.dataTable.ColReorder(table, false);  // turn re-order off
   new $.fn.dataTable.ColReorder(table, { "fixedColumnsLeft": 3 });  // turn re-order off

   new $.fn.dataTable.ColReorder(table, {
     "colReorder": {
       fixedColumnsLeft: 3
     }
   });  // turn re-order off

also tried using the fixed columns plugin without success

  new $.fn.dataTable.FixedColumns(table, {
    "fixedColumns": {
      leftColumns: 3
    }
  });

  new $.fn.dataTable.FixedColumns(table, {
     leftColumns: 3
  });

I have looked on all the forums and tried different options but no success.

Can anyone help?

Am also having a similar issue with the colresize plugin.
https://github.com/Silvacom/colResize

thanks
Az

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    edited May 2018

    Hi Az,

    That's not possible right now, there's no API method to enable/disable it post initialisation. We've create a bug for this, so hope to get the feature into a future release.

    colResize is third-party, so nothing to do with us I'm afraid.

    Cheers,

    Colin

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    I've just committed this feature and it will be in ColReorder 1.5.0 which I'll tag and release soon. The nightly will carry this fix in the next 5 minutes if you want to try it out soon.

    Allan

  • az1az1 Posts: 14Questions: 7Answers: 1

    Hi allan

    I have just tested your nightly build out and this is working nicely. I can now enable and disable the reordering at the click of a button.
    Can I use the nightly build in our code or should we wait for v1.5.0? Also when is that version expected to be released?
    I had a question about resetting the column visibility which I have raised as a separate issue.
    Finally are there any plans to release a colresize extension as the 3rd party ones all have issues!

    Thanks so much again for helping us out.

    regards
    Az (on behalf of SystemsLink)

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @az1,

    It's fine to use the nightly builds until the next versioned release is made. I would suggest not linking to that nightly URL though, as it is a nightly build and things may break. It would be worth sandboxing the version you're happy with, and then flip to the official build when it's released.

    Cheers,

    Colin

This discussion has been closed.