alert() in rowCallback

alert() in rowCallback

antoniocibantoniocib Posts: 277Questions: 62Answers: 1

Hi guys,
I need a simple little help where I am stuck and I can't figure out how to do it.

I would like to put an alert that displays the counter that is in the rowCallback, I tried in this way only that the alert comes out for every time the counter is updated

var count=0;
rowCallback: function ( row, data, ) {
var d = data.data_scadenza;
$('input.check_p', row).prop( 'checked', data.check_p == 1 );
if  ( new Date(d.substr(6,4) + d.substr(2,4) + d.substr(0,2)) < today )
{
count++;                    
$(row).addClass('myHighlight1')
$(row).removeClass('myHighlight')
}
    alert("Ci sono "+count+" fatture scadute" );
},

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,344Questions: 26Answers: 4,954
    Answer ✓

    Yes, the alert will show for each row that rowCallback processes. I'm guessing you want to show the alert once after Datatables initialization. In this case use initComplete to display the alert.

    Kevin

  • antoniocibantoniocib Posts: 277Questions: 62Answers: 1

    Solved in this way thanks @kthorngren is very easy to do!

    initComplete: function(settings, json) {
        alert("Al momento ci sono "+ count +" fatture scadute" );
    },
    
    rowCallback: function ( row, data, ) {
        var d = data.data_scadenza;
                    $('input.check_p', row).prop( 'checked', data.check_p == 1 );
    
                if  ( new Date(d.substr(6,4) + d.substr(2,4) + d.substr(0,2)) < today ){
                    count++;
    
                            $(row).addClass('myHighlight1')
                            $(row).removeClass('myHighlight')
                }
                        //alert("Ci sono "+count+" fatture scadute" );
                    },
    
Sign In or Register to comment.