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

79
Vistas
Problem with fixedColumns while reinitializing Datatable

I have a Data table with fixed columns. It is initialized in below way:

$('#someTable').DataTable({
        "dom" :'<flitp>',
        "columnDefs": [{"targets":[9,10], "searchable":false, "visible":false}],
        "pageLength": 10,
        "lengthMenu": [[100,150,250,500,-1], [100,150,250,500,"All"]],
        "fnInitComplete": function (oSettings, json) {
            /*let table = this.api();   
            new $.fn.dataTable.FixedColumns( table, {
                leftColumns:3,
                rightColumns:1,
            } );*/
        },
        "fixedColumns": {
            "leftColumns":3,
            "rightColumns":1
        }
    });

On initialization, Datatable adds attributes like 'left' and 'sticky' to these cells. Problem comes when I try to reinitialize the table.

dwr.util.removeAllRows("tableBody");
    if ( $.fn.DataTable.isDataTable( '#someTable' ) ) {
        $('#someTable').DataTable().clear().draw();
        $('#someTable').DataTable().destroy();
    }

I destroy table before making the table again. But after reinitialization, only headers remain fixed and not the body columns. For the cells in body position is set sticky but 'left' property is set to '0px' for all fixed columns. Any help appreciated. Edit - The above issue gets resolved when I sort the table or search something in the table - the table structure gets fine on its own. Not sure what's causing the issue.

Update - I figured out this issue is coming because I have kept last 2 columns as hidden. If I keep those columns visible I do not face this issue. Though I still need a solution for this!

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

0

As mentioned in my 'Update', this issue was because of hiding 2 columns and also fixing first few columns. My problem was solved by not defining the hidden column property in options, but hiding those columns later- after the table is initialized.

table.columns([9,10]).visible(false,true);
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