columnDefs, orderData, targets

columnDefs, orderData, targets

Lontar8Lontar8 Posts: 7Questions: 3Answers: 0

Please help, what is the purpose of targets?
here are some results:

columnDefs: [{
targets: [ 1 ],
orderData: [ 1,0 ]},

Airi Satou Accountant
Airi Satou Accountant
Airi Satou Accountant
Angelica Ramos Chief Executive Officer (CEO)

columnDefs: [{
targets: [ 0 ],
orderData: [ 1,0 ]},
Airi Satou Accountant
Airi Satou Accountant
Airi Satou Accountant
Garrett Winters Accountant
Angelica Ramos Chief Executive Officer (CEO)

thank you

Answers

  • Lontar8Lontar8 Posts: 7Questions: 3Answers: 0

    thank you @tangerine. indeed i read that link.
    orderData [1,0] to be sorted column 1 then column 0, but what is "targets" purpose?
    "columnsDefs.targets": Assign a column definition to one or more columns.

    as the above result, there will be different result when selecting targets 0 or 1.

    thank you

  • ApezdrApezdr Posts: 43Questions: 4Answers: 5

    The targets option as i understand it, determines which columns are affected when you trigger a sort on a column. If you define [0,1] it will affect the first and second column when you go to sort.

  • Lontar8Lontar8 Posts: 7Questions: 3Answers: 0

    thank you for the reply @Apezdr.

    https://jsfiddle.net/andrif/Lm9dpj0k/9/

    { "orderData": [ 4,3,8], "targets": [0] }, // (***)

    (***) these targets, will have the same result as expected.
    targets": [0]
    targets": [0,1]
    targets": [0,2]
    targets": [0,3]
    targets": [0,4]
    targets": [0,5]
    targets": [0,6]
    targets": [0,7]
    targets": [0,8]
    targets": [1,0]
    targets": [2,0]
    targets": [3,0]
    targets": [4,0]
    targets": [5,0]
    targets": [6,0]
    targets": [7,0]
    targets": [8,0]

    Once changed targets non "0", e.g "targets": [1] to "targets": [8]. Nothing happen as if it is pre-sorted. Why 0 is so defining column ???

    How about targets that has more one more level i.e
    "columnDefs": [
    { "orderData": [ 0, 1 ], "targets": 0 },
    { "orderData": 0, "targets": 1 },
    { "orderData": [ 2, 3, 4 ], "targets": 2 }
    ]

This discussion has been closed.