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

150
Vistas
use response data in columndef datatable jquery

I am using datatable jquery.I want to use Sr_no in data-id of td tag but How to get data of Sr_no.

or you can say that I want particular data from data reponse

I have highlighted in code

$("#fir").dataTable({
    "bProcessing": true,

    "sAjaxSource": "paid.php",
    "sDom": "<'row'<'col-sm-6'l><'col-sm-6'f>r>t<'row'<'col-sm-6'i><'col-sm-6'p>>",
    "sPaginationType": "full_numbers",
    "aoColumns": [

        {"mData": "Sr_no"}, <------ I dont want to add this column in table but I want to use value
        {"mData": "Category_Name"},
        {"mData": "Vendor_Name"},
        {"mData": "date"},
        {"mData": "Price"},
        {"mData": "Payment_Mode"},
        {"mData": "remark"},
        {"mData": "edit"},
        {"mData": "cancel"}
    ],
    'columnDefs': [
        {
           'targets': 1,
           'createdCell':  function (td, cellData, rowData, row, col) {
               console.log(row,col);
              $(td).attr('data-id',Sr_no);  <----------------
           }
        }

     ]

});



about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can use rowData.Sr_no to get the value of Sr_no for each row. Change targets: 1 to

{
   'targets': 1,
   'createdCell':  function (td, cellData, rowData, row, col) {
       console.log(row,col);
      $(td).attr('data-id', rowData.Sr_no);
   }
}
about 4 years ago · Juan Pablo Isaza Denunciar
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