Laravel datatables control cell value ?

Laravel datatables control cell value ?

Phoenix7sPhoenix7s Posts: 3Questions: 2Answers: 0
edited March 2020 in Free community support

The problem is that I need to automate my operations like this :

when click on one of the search buttons inside the datatable it opens a modal with another datatable and checkboxes (see screenshots), when checking in it fill that input text with the search button in the first datatable with data, how to do that ?

here is my code :

Controller :

//first datatable https://cdn.discordapp.com/attachments/295473977130876961/687592055630987282/unknown.png

public function getPersonnel_aff() {
        $mat = Materiel::select('id', 'mat_code', 'mat_designation');
        return DataTables::of($mat)
            ->addColumn('cherche_mat', function ($mat) {
                return '<div class="input-group no-border">
                            <input type="text" value="" class="form-control" disabled name="cherche_mat" id="' . $mat->id . '">
                            <button type="button" class="btn btn-white btn-round btn-just-icon cherche_mat" name="BtnRech" id="cherche_mat" data-toggle="modal" data-target=".materielModal">
                                <i class="material-icons">search</i>
                                <div class="ripple-container"></div>
                            </button>
                        </div>';
            })
            ->rawColumns(['cherche_mat'])
            ->make(true);
    }



//modal datatable https://cdn.discordapp.com/attachments/295473977130876961/687592442941407232/unknown.png

function getMateriel()
    {
        $data = Materiel::join('Types', 'Materiels.type_id', '=', 'Types.type_id')->join('Users', 'Materiels.user_id', '=', 'Users.id')
            ->select('Materiels.id', 'Materiels.mat_code', 'Materiels.mat_designation', 'Materiels.mat_ns', 'Types.type_designation', 'Materiels.mat_description', 'Materiels.note', 'Users.username', 'Materiels.mat_date');
        return DataTables::of($data)
            ->addColumn('modifier', function ($data) {
                return '<a href="#" class="btn btn-xs btn-warning Modifier" id="' . $data->id . '"><i class="material-icons">edit</i></a>';
            })
            ->addColumn('supprimer', function ($sup) {
                return '<a href="#" class="btn btn-xs btn-danger Supprimer" id="' . $sup->id . '"><i class="material-icons">delete</i></a>';
            })
            ->addColumn('check', function ($check) {
                return '<input type="checkbox" required="required" name="selected_materiels[]" class="check" id="' . $check->id . ' value="' . $check->id . '">';
            })
            ->rawColumns(['modifier', 'supprimer', 'check'])
            ->make(true);
    }

View :

$('#m_table').on('click', '.check', function() {
  if (this.checked == true) {
          $('.check').not(this).prop('checked', false);                      
                      var table = $('#m_table').DataTable();
                      data = table.row(this.closest('tr')).data()['data '];
                      //this should happen here
           }
     });

This discussion has been closed.