How do you change the style of cell in a JQuery.DataTable?

Posted by Sephrial on Stack Overflow See other posts from Stack Overflow or by Sephrial
Published on 2010-05-06T20:16:39Z Indexed on 2010/05/06 20:18 UTC
Read the original article Hit count: 325

Hello fellow coders,

I have a question about setting the style attributes for a data cell in the jQuery.DataTable. I was able to set the width for each column when initializing the dataTable using the following:

oTable = $('#example').dataTable( {
    "aoColumns" : [ 
        { sWidth: '40%' }, 
        { sWidth: '60%' }
    ]
} );

However, now I want to change the alignment for the second column like so: style="text-align: right;". I am adding rows dynamically:

/* Global var for counter */
var giCount = 2;

function fnClickAddRow() {
    oTable.fnAddData( [
        'col_1', 
        'col_2' ] );

    giCount++;  
}

Can you tell me how I can select the second cell of the added row after it's inserted? OR can you tell me how to set the style of the row before/during insertion? Any help would be greatly appreciated!

© Stack Overflow or respective owner

Related posts about jquery-plugins

Related posts about jquery-selectors