dynamically align a column of datatables (Jquery)

0

I have a datatable table in which I show some columns or others depending on a variable. The problem is that by changing the number of columns, I can not do column alignment with the target.

"columnDefs": [
                {className: "dt-body-right","targets": [3,10,11]},

            ],

How could a column be aligned, for example by its name?

"columns": [  {
                    "data": "name"
                }, {
                    "data": "fch_fin_prevista"
                }, ],
        });
    
asked by Lorenzo Martín 25.09.2018 в 14:02
source

1 answer

1

Try this structure:

columnDefs': [
  {
      "targets": 0, // Tu primera columna
      "className": "dt-body-right",
      "width": "4%"
 },
 {
      "targets": 2,
      "className": "dt-body-right",
 }],
    
answered by 25.09.2018 / 15:43
source