Sorting breaks when trying to use columns.orderData with order

Sorting breaks when trying to use columns.orderData with order

CagedEchoesCagedEchoes Posts: 2Questions: 1Answers: 0
edited July 2014 in Free community support

JS Fiddle

In my datatable, I have two columns which I want to do a multi-column default sort. However, the columns I want to sort by are for display purposes only, the actual values I want to sort by are in hidden columns. It worked in 1.9, but I'm trying to upgrade to 1.10 and change all the hungarian notation to camelcase. The code below (also in JS Fiddle link above) doesn't work... the columns aren't sorted and trying to click the header to sort does nothing:

$(document).ready(function () {
    var table = $('#example').DataTable({
        order: [
            [3, 'asc'],
            [1, 'asc']
        ],
        columns: [
        null, {
            orderData: 2
        }, {
            visible: false
        }, {
            orderData: 4
        }, {
            visible: false
        }]
    });
});

If I change the orderData to iDataSort, everything works as expected, but I'm trying to get away from the hungarian notation.

If I change the order to use columns besides the columns that contain orderData... that also works, but then I don't get the columns being sorted the way I want.

Any ideas? Is this a bug or is there a new way to do this?

This question has an accepted answers - jump to answer

Answers

  • rhinorhino Posts: 80Questions: 2Answers: 17
    Answer ✓

    Seems to work if I just make this change:

              orderData: [2]
    
    //...
    
              orderData: [4]
    
  • CagedEchoesCagedEchoes Posts: 2Questions: 1Answers: 0
    edited July 2014

    Ah, good catch. According to the documentation, orderData should also accept an integer, but I'm fine with using a single-value array.

  • rhinorhino Posts: 80Questions: 2Answers: 17

    You're right, I wonder if it's a bug...

  • allanallan Posts: 61,663Questions: 1Answers: 10,094 Site admin

    Its a bug. Thanks for letting me know.

    Allan

This discussion has been closed.