Default ordering when using columnDefs and a plugin

Default ordering when using columnDefs and a plugin

boomerboomer Posts: 2Questions: 1Answers: 0

Hey guys,

Been trying to get this squared away for about a day now so I figured i'd come and see if anyone can help. Going through the docs it shows how to order and how to add plugins. I have yet to find anything about combining the two together that worked. I have tried these two things

    $("#jobs-reports-table").DataTable({
      columnDefs: [{
        type: 'any-number', targets: 7
      }],
      "order": [[7, 'asc']]
    })

this sets the correct target by default but the plugin no longer works. Then I tried the following

    $("#jobs-reports-table").DataTable({
      columnDefs: [{
        type: 'any-number', targets: 7
      },
      {
        "orderSequence": ["asc"], "targets": [7]
      }],
    })

This does not set the target to a default order but does keep the any-number plugin working

TLDR; I have the plugin working perfectly fine but I would like to set that column to asc by default otherwise the data is all jacked up on initial page load.

Thanks for all the help guys much appreciated!!!

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,598
    Answer ✓

    Hi @boomer ,

    I suspect you've misread columns.orderSequence - that option allows you to change the behaviour of the sorting. To set the initial sorting, use order. If that doesn't help, could you link to your page or create a test case, please. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • boomerboomer Posts: 2Questions: 1Answers: 0

    Thanks for that. As you can see in my examples shared when I use the order property it makes it so the plugin any-number stops working. When I put it in a jsbin it works perfectly fine. So it must be something with my Rails application. I'll have to look into that. Thanks for the help!!

This discussion has been closed.