Hide column based on column header.

Hide column based on column header.

MickBMickB Posts: 103Questions: 25Answers: 2

Hi,

Is there a way to do this?

I am currently doing this, to hide the last column:

"columnDefs": [
                {
                    "targets": [-1],
                    "visible": false,
                    "searchable": false
                },

Now I would prefer to hide it based on the column header (field name).

One of my columns dictates what colour the row should be highlighted and I want to be able to hide it, based on it's name.

Mick

This question has an accepted answers - jump to answer

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    you could do it in initComplete callback

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Answer ✓

    Yes - you can't select columns based on the name during initialisation I'm afraid (unless you do some jQuery trickery). You need to use a callback function as @bindrid says.

    Allan

  • MickBMickB Posts: 103Questions: 25Answers: 2

    I cheated and worked out the index in PHP, then passed it in:

         {
                        "targets": [{{$hideColumn}}],
                        "visible": false,
                        "searchable": false
                    },
    

    Mick

This discussion has been closed.