dimanche 8 décembre 2019

How do I pass the value of the rows from the crud table to the custom submit button

this is the tab i have implemented and fetched the datas from an another crud controller

I have tried using bulk action to select the row and pass the value of the row to the custom button But i couldnt

I have also tried by using j query as well but it didnt worked well

$(document).ready(function (){

        var table = $('#crudtable').DataTable({
           'data': userData,  
           'columnDefs': [{
              'targets': 0,
              'searchable':false,
              'orderable':false,
              'className': 'dt-body-center',


        });


        $('.crud_bulk_actions_row_checkbox').on('click', function(){
           // Check/uncheck all checkboxes in the table
           var rows = table.rows({ 'search': 'applied' }).nodes();
           $('.crud_bulk_actions_row_checkbox', rows).prop('checked', this.checked);
        });


        $('#crudtable tbody').on('change', ''.crud_bulk_actions_row_checkbox', function(){
           // If checkbox is not checked
           if(!this.checked){
              var el = $('#example-select-all').get(0);

              if(el && el.checked && ('indeterminate' in el)){

                 el.indeterminate = true;
              }
           }
        });

        $('#crudtable').on('#button3', function(e){
           var form = this;

           // Iterate over all checkboxes in the table
           table.$('.crud_bulk_actions_row_checkbox').each(function(){
              // If checkbox doesn't exist in DOM
              if(!$.contains(document, this)){
                 // If checkbox is checked
                 if(this.checked){
                    // Create a hidden element 
                    $(form).append(
                       $('<input>')

                          .attr('name', this.name)
                          .val(this.value)
                    );
                 }
              } 
           });
      });



Aucun commentaire:

Enregistrer un commentaire