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: 9,175Questions: 0Answers: 1,533

    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: 52,268Questions: 1Answers: 7,958 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.