"createdRow" function use to click button and it shows alert

"createdRow" function use to click button and it shows alert

che_jayche_jay Posts: 8Questions: 3Answers: 0

Hi,

$(document).ready(function() {
$('#example').DataTable( {
"createdRow": function( row, data, dataIndex ) {
if(data[4]=="some value"){
$(row).addClass('red');
}

I wrote this function and it's working.but Now I have another
problem.I want to add button called "next action" to rows that
are fulfill below condition.
if(data[4]=="some value")
not only that,when I click this button It's must be show alert
box.How can I do this.please help me.

Answers

  • allanallan Posts: 63,812Questions: 1Answers: 10,516 Site admin

    To show the button I would strongly suggest you use a renderer rather than createdRow.

    For the event handler, see this example.

    Allan

  • che_jayche_jay Posts: 8Questions: 3Answers: 0

    thank you.

    but my question is how to add button to selected rows.as example,

    ID|Name|Age| |Address
    01|Ann |23 | button |"12",west street.London
    02|Mark |35 | button |"34",north street.UK

    my table is like this. If Age==23 , then I click button and It must shows alert box like
    alert("Take action B") .

    please help me

  • allanallan Posts: 63,812Questions: 1Answers: 10,516 Site admin

    I understood the question :smile:. As I said, use a renderer to create the button (you would use it as a function and the function would perform whatever logic check you need).

    If you need to write an example for you, that would be covered by the support options.

    Allan

This discussion has been closed.