Generate checkbox in the Datatable by sDefaultContent with different IDs

1

I am generating a checkbox for each row of the DataTable through sDefaultContent, but when I perform an action on one of the checkboxes, it replies to all others. I'm having trouble generating a checkbox with a different ID for each line.

Follow the current code:

"aoColumnDefs" : [
            //adiciona a classe para todas as células referente a coluna indicada
            {"sClass" : "hidden-xs sorting","aTargets" : [1]},              
            {"sClass" : "alignbutton","mData": "", "sDefaultContent": "<input type='checkbox'  name='ckbPremiacao' class='ckbPremiacao' style='text-align:center'  onchange='alteraPremiacao()' ></input><script>$('.ckbPremiacao').bootstrapSwitch();</script>","aTargets": [3]}
        ]

Does anyone know how to help me? [URGENT]

    
asked by anonymous 10.12.2015 / 13:18

1 answer

0

I recommend using createdRow , it runs every% of% created. This way you will be able to assign events and even use tr on the specific line.

Perhaps combining this approach with columns.render can be of some use, as it also has access to line, consequently it is possible to generate an id for the checkbox.

    
21.12.2017 / 02:41