Table informing if it has a scrollbar
Table informing if it has a scrollbar
Hello everyone,
I'm having layout problems (but specifically header formatting) with a datatable after including a scrollbar in it. I even managed to get the table to render itself satisfactorily when the scrollbar was present. The problem was that when the scrollbar didn't appear, the code I did ended up harming the layout of the table.
I would like to know if there is any method or attribute on the part of the table where I can know if the scrollbar is present or not. Knowing if the scroll is present or not, it is easy to apply the formatting codes.
Observation: this table of my it is updated from time to time to receive data. And always in the second update, it is rendered with the correct layout (it only gets the layout broken in the first rendering). Does anyone have any idea why this?
This question has accepted answers - jump to:
Answers
Hi @marceltpo ,
That second update does seem odd being correct does seem odd. We're happy to take a look if you could link to the page.
Cheers,
Colin
Hi @colin, here's a example of what i was saying about the observation:
In the first rendering of the table, the headers always get this crap. When the table refreshes (when I click on the header, for example), then it stays the correct way.
Hi @marceltpo ,
We're happy to take a look, but it would help, as per the forum rules, if you could link to a running test case showing the issue so we can offer some help. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Hi @colin,
It will be very difficult to create the conditions in another code to show the problem I am currently having. However, maybe you can help me with something else: what is the code that is executed when we click on the header of the table?
Like happens in https://datatables.net/forums/discussion/41587, when I click in header, the layout of header back to normal.
I discovered the reason for my header rendering problem. As in example (https://datatables.net/forums/discussion/41587), my datatable was not visible when it was started (it was in a modal window). Then I realized that it could only render without any problem when the window was active and the view.
Ah, yep, glad to hear you got it sorted!
Yes, when the table is made visible you need to call
columns.adjust()
to tell DataTables that it is now visible.I've got a plan for v2 to make that automatic...
Allan
Hi @allan
I got to use this API solution (columns.adjust()), but I was calling the method when the window wasn't visible. And seeing now, it makes perfect sense not to have worked before.
Thanks by the tip.