Styling cells based on value

Styling cells based on value

neburtonneburton Posts: 63Questions: 6Answers: 0

Previously I have applied styles to individual cells based on their content during the fnRowCallback utilising the fnGetTds plugin.

"fnRowCallback": function( nRow, aData, iDisplayIndex ) 
{
var value= aData[0];
if (value=='1')
{
$(this.fnGetTds(nRow)[5]).addClass('ui-state-error');
}               
return nRow;
}

I was using fnGetTds rather than a standard jQuery selector, as the first column was hidden.

I cannot figure out how to achieve this with DataTables 1.10 and the new API. I've been reading up on .cell() and .cells() but not getting very far. as there are few examples in the reference at present.

Answers

  • neburtonneburton Posts: 63Questions: 6Answers: 0

    Managed to figure this out myself.

    "createdRow": function( row, data, dataIndex ) 
    {
    var alert = data[0];
    if (alert=='1')
    {
    $(rightopportunitiestable.cell(row,8).node()).addClass('expired');
    }
    },
    
    
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    The columns.createdCell option is another option.

    Allan

This discussion has been closed.