Apply function on "table header names"

Apply function on "table header names"

hpegmslicensemgmthpegmslicensemgmt Posts: 21Questions: 6Answers: 0

Dear all,
I'm currently using the createdCell function of datatables to colorize the tables depending on the value of the cell and it works perfectly well when I know in which column the data is being located by using the "targets" option.

However, I now have a new challange, where I have dynamically generated tables and where the location of the "targets" can be different. (eg. table 1 = pos 5; table 2 = pos 4 etc.)

The tables have the same Header Names eg. <th>Status</th> ...

Is there a clever way to translate the Header Names into Column Indexes ?

Best regards,
David

Answers

  • kthorngrenkthorngren Posts: 19,149Questions: 26Answers: 4,537
    edited February 21

    See the columnDefs.targets docs for the options you can use to select the columns. If you can apply a calssname to the th then use that as the columnDefs.targets selector.

    Kevin

  • hpegmslicensemgmthpegmslicensemgmt Posts: 21Questions: 6Answers: 0

    Dear Kevin,
    This works perfectly well :-)
    Did I already tell you that I LOVE DataTables ?
    Best regards,
    David

Sign In or Register to comment.