Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

163
Vistas
Adding buttons to datatable - JQuery

below is my simple viewing using datatable. How can I add buttons to my datatable? I have a simple viewing of data after button onclick. What I want is to have a button as the 4th column for insert query purposes. How can I embed it on my codes? Thanks in advance.

enter image description here

My script

function view() {
      let EmployeeID = document.getElementById('employee-id').value;
      console.log(EmployeeID);
      let testTable = $('#table_view').DataTable();
      $.ajax({
         type: "POST",
         dataType: "json",
         url: "@Url.Action("ViewEmployee")",
         data: {
            'EmployeeID': EmployeeID,
           },
           beforeSend: function () {
              $.dialog({
                 icon: 'fa fa-spinner fa-spin',
                 title: 'Loading',
                 content: 'Loading, Please Wait...',
                 showConfirmButton: false,
                 draggable: false,
                 closeIcon: false
              });
           },
           success: function (result) {
              var delay = 500;
              $('.jconfirm').fadeOut(delay);
              var interval = setInterval(function () {
                 clearInterval(interval);
              }, delay)
                if (result.success) {
                   var columns = []
                   var jsonData = $.parseJSON(result.data);
                   var json = jsonData.Table = null ? '' : jsonData.Table;

                   if (json.length > 0) {
                      var colNames = Object.keys(json[0])
                      for (var i in colNames) {
                         columns.push({ data: colNames[i], title: colNames[i], className: colNames[i],});
                      }

                      testTable.destroy()
                      testTable.clear().draw()

                      $('#table_view').empty()
                      $('#table_view').DataTable({
                         //dom: 'Bfrtip',
                         columns: columns,
                         data: json,
                         scrollX: true,          
                      });
                   }
                   else {
                      testTable.destroy()
                      testTable.clear().draw()
                   }
                }
                else {
                    alert(result.message);
                }
           }
      });
   }
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda