ColReorder does'nt work

ColReorder does'nt work

sabricksabrick Posts: 10Questions: 4Answers: 0

ColReorder.fnReset(oTable) doesn't work. It should be reordering all the columns back to what they were originally

The ColReorder object doesn't even exist even though I have imported the colReorder.js file.
I have used this before in a previous project and I'm using this exact code:

ColReorder.fnReset(oTable)

and it works fine, but in this project no luck.
Any suggestions?

Answers

  • sabricksabrick Posts: 10Questions: 4Answers: 0

    $('._reportTable').dataTable().colReorder.reset()

    doesn't work either, the colReorder object doesn't exist.

  • sabricksabrick Posts: 10Questions: 4Answers: 0

    I'm using 1.9.4 btw

  • RpiechuraRpiechura Posts: 98Questions: 3Answers: 14

    What version of ColReorder are you using?

  • sabricksabrick Posts: 10Questions: 4Answers: 0

    @Rpiechura: 1.1.1

  • sabricksabrick Posts: 10Questions: 4Answers: 0

    I've even taken every other mod out and did this:

    colReorder: { order: [1, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10] }

    And it's STILL ignoring the column order. I can even put as many numbers as I like in there it doesn't even read it!

  • RpiechuraRpiechura Posts: 98Questions: 3Answers: 14

    Silly question, but you made sure that in your initialization code that you're doing something like

    "sDom": 'R<"clear">lfrtip'
    

    right? Because if you're not than you're not telling the datatable to use the reorder plugin.

  • RpiechuraRpiechura Posts: 98Questions: 3Answers: 14

    So after messing around with it the past half hour, it appears that something change from 1.0.8 to 1.1.0 (let alone 1.1.1) which makes you have to do things differently. The project you were using it probably had 1.0.8 which is why it worked. I'm gonna see if I can't figure out how you're supposed to do it now, however if you were to go back to using that version things should work just fine for you.

  • RpiechuraRpiechura Posts: 98Questions: 3Answers: 14
    edited May 2014

    http://datatables.net/extensions/colreorder/api, the code you're looking for is...

    var table = $('#example').dataTable();
    var colReorder = new $.fn.dataTable.ColReorder( table, {
        "aiOrder": [ 4, 3, 2, 1, 0 ]
    } );
    

    That will set up the order, to call it you want to do...

    colReorder.fnReset();
    return false;
    
This discussion has been closed.