How to loop on each td using createdRow?

How to loop on each td using createdRow?

ziv@kpmbro.comziv@kpmbro.com Posts: 73Questions: 28Answers: 4

Hello

I want to change the td color base on his value, so i am looping on the rows using createdRow, but it gives me the data for each row, how can i loop on that data(td's)?

i need something like this:

  "createdRow": function( row, data, dataIndex ) {


     if ( data.every().cell() == "TRUE" ) {
      $(cell).addClass( 'green' );
     }else 
{
 $(cell).addClass( 'red' );
}
  }

This question has an accepted answers - jump to answer

Answers

  • ziv@kpmbro.comziv@kpmbro.com Posts: 73Questions: 28Answers: 4

    found it

     "createdCell": function (td, cellData, rowData, row, col) {
        console.info('td: ',td);
        // console.info('cellData: ',cellData);
        // console.info('rowData: ',rowData);
        // console.info('row: ',row);
        // console.info('col: ',col);
        // console.info('dataIndex: ',dataIndex);
        if ( $(td).text()== "TRUE" ) {
          $(td).css('color', 'red')
        }else if()
        {
            $(td).css('color', 'green')
        }
      },"aTargets": [ "_all" ],
    }
    
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Answer ✓

    Or use $('td', row).addClass(...) in createdRow.

    Allan

  • ziv@kpmbro.comziv@kpmbro.com Posts: 73Questions: 28Answers: 4

    Thanks Allan :)

This discussion has been closed.