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

88
Vistas
Export from datatable only selected columns

I am trying to export a datatable to a excel, pdf and just to copy it. But i just want to export the selected columns from colvis. When i am exporting the table, it always shows me the full datatable. Where is my mistake?

Thx

<script type="text/javascript" language="javascript">
    $(document).ready(function() {
        $('#tbl').DataTable( {
        dom: 'lBfrtip', 
        language: {
            searchBuilder: {
                button: 'Filter',
            }
        },
        buttons:[
            'searchBuilder',
            {
            extend: 'colvis',
                collectionLayout: 'fixed columns',
                collectionTitle: 'Spalten Auswahl'
            },
            {
            extend: 'copy',
            text: 'Copy',
            exportOptions: {
                modifier: {
                    columns: ':visible'
                }
            }
        }, {
            extend: 'excel',
            text: 'Excel',
            exportOptions: {
                modifier: {
                    columns: ':visible'
                }
            }
        }, 'pdf'        
        ],       
        colReorder: true
        //scrollX: true,
    });
}); 
</script>
almost 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Instead of this:

exportOptions: {
  modifier: {
    columns: ':visible'
  }
}

Just use this:

exportOptions: {
  columns: ':visible'
}

An example is provided here: Export options - column selector. This is for the print button, but it is the same for the other buttons.

columns: The column selector to use. Default - all columns.

The modifier option is used to control something different:

modifier: How the ordering and search state of the table should be applied. Default - {search: 'applied', order: 'applied'}

almost 4 years ago · Santiago Trujillo 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