FixedColumn calculating incorrect column width with changing column.visible()
FixedColumn calculating incorrect column width with changing column.visible()

I have an example of this in: http://live.datatables.net/hisajofe/1/
If you use the dropdown on the top of the page to change which columns are visible, fixed columns will occasionally compute the incorrect column size. Changing from showing by the Position to showing All is the most repeatable change that will mess up for me. The strange part is that the total width of the visible fixed columns is always correct. Any ideas on why this is happening or what I can do to fix it?
This discussion has been closed.
Replies
Hi @djkong7 ,
I added a call to
columns().adjust()
and that seems better here.Cheers,
Colin
Hey @colin ,
This didn't appear to solve the issue at all for me. Any other ideas?
Thanks,
Dan
Need to do a
draw()
on the table as well to allow the scrolling column alignment to update: http://live.datatables.net/hisajofe/4/editAllan
Ahhh. That's what I was missing. That works. Thank you!
@allan, This solution does work, but I am using server side in my actual implementation and calling draw results in an unnecessary call to the server. Some of my search queries can take up to 20 seconds to return, so a call to the server to load the same data is problematic. I tired calling draw() with each of the 3 possible parameters with no luck. Is there a way to call draw() without a call to the server or a different way to get the column widths to correctly calculate?
Because I'm now calling adjust on the columns, I figured it would be best to change the visibility with visibility([true/false], false) to get a little performance boost. Unfortunately, this is really messing with Fixed Columns and the fixed column column titles aren't changing. Example at http://live.datatables.net/hisajofe/13/ . Any thoughts on this issue?
Call
draw()
withfalse
as its only parameter: http://live.datatables.net/hisajofe/14/edit .Allan
This did not solve either issue for me. I would love to create an example but I'm unsure how to create a server side example.
Hi @djkong7 ,
This example here is using server-side processing - could you blend that in with your current example to demonstrate the issue?
Cheers,
Colin
Hey @colin
Here is a working example of this issue http://live.datatables.net/bareyifa/2/ . The processing indicator shows up and Chrome network monitor shows a request going out.
Thank you,
Dan
Hi Dan,
You are right - my apologies. I've given you dodgy information there.
The key here is that we need to trigger DataTables scroll draw function - there isn't an external API for that other than the
draw()
method currently. But we could do a hacky little workaround in this case:http://live.datatables.net/bareyifa/3/edit
Allan
@allan and @colin ,
I wanted to say thank you both so much for taking the time out of your days to help! With the fixes you provided, I was able to get the tables to render correctly with no side effects. You two provide some of the best support I've experienced.
Thank you again,
Dan
Hi @djkong7 ,
Thanks for the feedback, glad to know we're helping
Cheers,
Colin