targets : '_all' not working on some columns

targets : '_all' not working on some columns

oms02oms02 Posts: 11Questions: 3Answers: 0

I want to add bootstrap class "align-middle" to all the cells. In general it woks fine but I just awared that there're some cells in which it doesn't work. I don't know if it's just a coincidence or not but the cells in where it doesn't work has numbers as content. In that cells the class hasn't be applied.

    "columnDefs": [
        {
            targets : '_all',
            className : 'align-middle'
        }
    ]

Any ideas about this behaviour?

My apologize about the english level.

Thanks in advance!! :smile:

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,468Questions: 1Answers: 10,466 Site admin

    That suggests that you have some other style overriding it.

    We'd need a link to the page to be able to help further.

    Allan

  • oms02oms02 Posts: 11Questions: 3Answers: 0

    Hi allan. Thanks for your answer.

    You were right. The "guilty" was other "rule" applied just before:

        "columnDefs": [
            {//this was the problem
                targets : [0,4,7,8,9],
                className : 'text-center'
            },
            {
                targets : '_all',
                className : 'align-middle'
            }
        ]
    

    do you know how could I set both properties?:
    * align-middle class for all the cells and
    * text-center class for some cells.

    Thanks in advance!! :wink:

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    Maybe try reversing so you add align-middle to all then text-center to the others.

    Kevin

  • oms02oms02 Posts: 11Questions: 3Answers: 0

    Hi kthorngren.

    I already tried that but the result was just the opposite: it adds the align-middle class to all the cells but the text-center class wasn't added for anyone.

  • oms02oms02 Posts: 11Questions: 3Answers: 0

    I think definitively there's a problem with that.

    I just copied the example for doing this (a class name for all the columns and an aditional class name for just one column) and it's not working:

    columnDefs: [
    { className: "my_class", targets: "_all" },
    { className: "my_second_class", targets: 1 }
    ],

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947
    Answer ✓

    How about this:

    columnDefs: [
      { className: "my_second_class my_class", targets: 1 },
      { className: "my_class", targets: "_all" },
    ],
    

    Kevin

  • oms02oms02 Posts: 11Questions: 3Answers: 0

    Perfect @kevin
    That works!

    Thanks!! :smile: :smile:

This discussion has been closed.