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

382
Vistas
Jquery datatables custom button for export

I have a data table that has 2 buttons, the export for pdf and csv. My colleague asked me if possible, there is only one button in the table and when the user clicks it, it will automatically download two file types. The CSV and the PDF one. Is that possible? Thanks for answering.

Currently my datatable code is

        $('#apparatus-table').DataTable( {
            pageLength: 5,
            dom: 'Bfrtip',
            buttons:[
                        {
                            extend: 'csv',
                            className: 'grantors-btn rounded-full font-bold bg-indigo-500 px-4 py-2 text-white',
                            text: 'CSV',
                        },
                        {
                            extend: 'pdf',
                            className: 'grantors-btn rounded-full font-bold bg-indigo-500 px-4 py-2 text-white',
                            text: 'PDF',
                        },
                    ],

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

0

It's not possible but you can make a workaround. You can bind an event to both the buttons in order to trigger the other button click event, but you have to be carefull, because you can crush your website if you don't take in consideration the recursion that might happen. Code like this make an infinite loop and deplete your heap really quickly:

// NOT TO USE 
$(".buttons-pdf").on("click",()=> $(".buttons-excel").trigger("click"));
$(".buttons-excel").on("click",()=> $(".buttons-pdf").trigger("click"));

You might consider something more elaborate, with some event propagation controll or event manipulation, but it might be not worth it.

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