Using a class for targets to ordering,displaying in columnDefs
Using a class for targets to ordering,displaying in columnDefs
itajackass
Posts: 162Questions: 48Answers: 3
My actual option is:
indexes 0 and 6 are dates in the format YYYY-MM-DD.
"columnDefs": [
{ "orderable": false, "targets": 'azioni' },
{
targets: [0],
data: {
_: "0.display",
sort: "0.@data-order",
type: "0.@data-order"
}
},
{
targets: [6],
data: {
_: "6.display",
sort: "6.@data-order",
type: "6.@data-order"
}
}
]
It works great, but sometime i've to add new columns in the middle, for example in index 2. In this case i've to manually alter also the code to increment by 1 like:
targets: [7],
data: {
_: "7.display",
sort: "7.@data-order",
type: "7.@data-order"
}
Is there a way to create a global option like this?
"columnDefs": [
{ "orderable": false, "targets": 'azioni' },
{
targets: [ column_with_class_date], // i've 2 column with date start and date end
data: {
_: "column_with_class_date.display",
sort: "column_with_class_date.@data-order",
type: "column_with_class_date.@data-order"
}
}
]
This discussion has been closed.