how to add data to attributes in edit custom button

how to add data to attributes in edit custom button

cris19ncris19n Posts: 55Questions: 18Answers: 0
edited December 2020 in Free community support
"columns": [
                        { data: 1 },
                        { data: 2 },
                        { data: 3 },
                        {"defaultContent":"<button type='button' class='editarprueba btn btn-warning' ideditar='+{ data: 1 }+' data-toggle='modal' data-target='#edicion'>Editar</button>"}
                    ]

ideditar='+{ data: 1 }+'
I want to add the data to certain attributes, but I don't know what is the best way to do it, which is similar to the example

Answers

  • cris19ncris19n Posts: 55Questions: 18Answers: 0
    edited December 2020

    my solution

    example edit button

    {

                            "render": function ( data, type, row ) {
    
                                var idus = $('#variable_sesion2').val();
                                var user = $('#variable_sesion').val();
    
                                console.log(row[0]);
    
    
                                return '<div class="btn-group" role="group" aria-label="Third group"><button class="btn btn-warning btnEdit manito-clic" editMp='+row['0']+' idUs='+idus+' User='+user+' data-toggle="modal" data-target="#modalEditarTable"><i class="fa fa-pencil"></i></button> </div> <div class="btn-group" role="group" aria-label="Third group"> <button class="btn btn-danger btnDeletedt manito-clic" deleteid='+row['cod_id']+' lotep='+row[3]+' viajep='+row[5]+'><i class="fa fa-times"></i></button></div>';
    
                            }
                        }
    
This discussion has been closed.