Show/Hide columns and fnGetTds error

Show/Hide columns and fnGetTds error

LilithLilith Posts: 6Questions: 2Answers: 0
edited October 2018 in Free community support

Hello !

I use the Show/hide columns method explained here https://datatables.net/examples/api/show_hide.
But I also need to custom my cell with a specific class in function of data.
So I have in rowCallback:
'rowCallback':

            function (row, data, dataIndex) {
                if ((data[10] === 6 && data[9] === "OK") || (data[10] === 7 && data[9] === "NOT"))
                    $(row).find('td:eq(9)').addClass('isOK');
                else
                    $(row).find('td:eq(9)').addClass('notOK');

But, when I enable/disable the show/hide button, the style is apply on the wrong cell.
I found someone with the same problem as me here : https://datatables.net/forums/discussion/6940, so I decide to change $(row).find('td:eq(9)').addClass('isOK'); to $(this.fnGetTds(row)[10]).addClass('isOK'); But I have the error:
oSettings.aoData[iRow]._anHidden is undefined (in Firefox)

In my columnDefs menu I have some columns invisible at the initiation of the datatable, and I notice that when I delete this "visible : false", there no problem with fnGetTds

Where's my mistake ?

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @Lilith ,

    That other forum thread is so old, it's unlikely to be relevant. We're happy to help, but it's hard to understand what's going on without seeing more of your code. If you could link to a running test case showing the issue we can offer some help. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • LilithLilith Posts: 6Questions: 2Answers: 0

    For those who are interested, I solved my problem by replacing
    $(row).find('td:eq(9)').addClass('isOK');
    by
    $(table.cell(row, 10).node()).addClass('isOK');

This discussion has been closed.