How to get table id in drawCallback

How to get table id in drawCallback

mp108mp108 Posts: 3Questions: 2Answers: 0

I want to style <td> elements in a column <th> named "Change" and do this in the function called for 'drawCallback' option which is passed this.api().

I cannot see any way to access column headers from this.api() object so once I know the table's id, I select the <th> for it.

By examining the this.api() object, I found two ways to achieve this but am wondering is there a documented function to either give me the column headers or the table id?

How I get table id from this.api()

function adjustTableWidth(api){
    :
    var tableId = api.tables().nodes().to$().attr('id');


function decorateTable(api){
    var tableId = api.context[0].sTableId;;

Answers

  • mp108mp108 Posts: 3Questions: 2Answers: 0

    By the way, call back option in my dataTable definition:

    'drawCallback': function( settings ) {
        var $nTable = $(tableId);
        // do some stuff
    
        // call callback function
        if(fnDrawCallback){
            fnDrawCallback(this.api());
    }
    
This discussion has been closed.