How do i get the classname of autofill cells.

How do i get the classname of autofill cells.

KelvinDingKelvinDing Posts: 11Questions: 4Answers: 0

How do I get the classnames of those cells that was selected during autofill?

   $('#TestTable').DataTable().on( 'autoFill', function ( e, datatable, cells ) {
                                var x = table.cells('.PublicHoliday');
                                alert(cells[0].className);
                                alert( (cells.length * cells[0].length)+' cells were updated' );
                            } );

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @KelvinDing ,

    You can look over the cells array, and use

    cells[0].cell.className
    

    Cheers,

    Colin

  • KelvinDingKelvinDing Posts: 11Questions: 4Answers: 0

    Hi @colin ,

    Thank you for your quick response.

    Gave your answers a try but I have encountered this problem.

    I have tried it this way as well but was given undefined.

    Do you happen to know what went wrong?

    Cheers,
    Kelvin

  • allanallan Posts: 63,678Questions: 1Answers: 10,498 Site admin
    Answer ✓

    Ooops - sorry. That's my fault. I gave Colin some dodgy advice :).

    The cell property is an API instance containing the cell index, so:

    cells[0].cell.node().className
    

    should do it!

    Allan

  • KelvinDingKelvinDing Posts: 11Questions: 4Answers: 0

    @allan

    Thanks for your prompt reply.

    I was able to achieve what i wanted by doing what you have suggested however with a slight change.

    cells[0][0].cell.node().className
    
This discussion has been closed.