Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

78
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda