How do I include a column with a checkbox for all rows in the DataTable?

1

I would like to put a column at the end with a checkbox or toggle switch button for all lines coming from an ajax call.

I was able to put by sDefaultContext and mRender, but the checkbox does not work, it does not recognize the click.

Does anyone know how to solve it?

I currently use the following code snippet:

        "aoColumnDefs" : [
            //adiciona a classe para todas as células referente a coluna indicada
            {"sClass" : "hidden-xs sorting","aTargets" : [1]},
            {"mData": null, "sDefaultContent": "<input type='checkbox' name=''></input>","aTargets": [3]}
        ]
    
asked by anonymous 07.12.2015 / 14:40

1 answer

1

Hello,

Do so

function MeuMetodo(){
alert('Faça o que quer aqui');
}

 "aoColumnDefs" : [
            //adiciona a classe para todas as células referente a coluna indicada
            {"sClass" : "hidden-xs sorting","aTargets" : [1]},
            {"mData": null, "sDefaultContent": "<input onclick='MeuMetodo();' type='checkbox' name=''></input>","aTargets": [3]}
        ]

You can not give Jquery Bind on dynamically added elements, unless you read the code that makes Bind after adding the HTML element.

    
07.12.2015 / 15:50