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

907
Visualizações
DataTables: When scroll bar of tbody is hidden, fixed column gets messed up

I've got a table which includes:

  1. first Column is fixed
  2. tfoot
  3. horizontal scroll bar of tfoot
  4. have hidden horizontal scroll bar of tbody.

Fiddle: https://jsfiddle.net/jbeteta/6sxh3gbk/12/

enter image description here

    $(function() {
              $('#example').DataTable({         
            "fnInitComplete": function () {
                        // Disable scrolling in Head
                        $('.dataTables_scrollHead').css({
                            'overflow-y': 'hidden !important'
                        });

                        // Disable TBODY scroll bars
                        $('.dataTables_scrollBody').css({
                            'overflow-y': 'scroll',
                            'overflow-x': 'hidden',
                            'border': 'none'
                        });

                        // Enable TFOOT scoll bars
                        $('.dataTables_scrollFoot').css('overflow', 'auto');

                        //  Sync TFOOT scrolling with TBODY
                        $('.dataTables_scrollFoot').on('scroll', function () {
                            $('.dataTables_scrollBody').scrollLeft($(this).scrollLeft());
                        });

                    },
                scrollX: true,
                paging: true,
                fixedColumns: {
                  leftColumns: 1
                }
 });
        });

In that scenario, when you scroll to the right side, you will see that last row cell of fixed Column (background color: red) get messed up, because horizontal <tbody> scroll bar is hidden.

My question: Is there any way to correct this?

By the way: I had to hide <tbody> horizontal scroll bar because it doesn't get syncronized with <tfoot> scroll bar.

Many thanks

EDIT: In Chrome is the same:

enter image description here

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Here is a partly solution. The entire setup is a huge mix of different tables and divs. For some reason the hidden scrollbars still is in "effect" for several of the divs, i.e they still take up space and react when other elements is being scrolled. Perhaps really, really careful try and error CSS-ing on each element / container could solve the overall problem, but to me it seems like expected browser behaviour, simply "as it is". But on webkit-browsers you can do this :

div:not(.dataTables_scrollFoot)::-webkit-scrollbar { 
  display: none; 
}

https://jsfiddle.net/6sxh3gbk/19/

This will effectively disable all the nasty hidden (but not really hidden) scrollbars on the injected <div> elements, but preserve them on the footer element which we want to scroll with.

But this does only apply to webkit browsers: Chrome, chromium, Safari, Opera and Android.

Gecko (mozilla) once had a similar feature -moz-scrollbars-none but it was deprecated and left out. AFAIK there is a permanent cry for bringing it back.

This is also the case for Edge, the issue is still being raised. For Edge there is real hope, since MS many times have stated that EdgeHTML is meant to be fully compatible with the WebKit layout engine.

So a partly solution, covering perhaps 85%, all devices included.

over 4 years ago · Santiago Trujillo Relatório

0

Please check..

  1. first Column is fixed
  2. tfoot
  3. horizontal scroll bar of tfoot
  4. have hidden horizontal scroll bar of tbody.

this problem has been solved. Your ans is given below link..

$(function() {
      $('#example').DataTable({         
     scrollY:        "300px",
    scrollX:        true,
    scrollCollapse: true,
    paging:         false,
    fixedColumns:   {
        leftColumns: 1
    }
      });
    });

Fiddle

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