Fixed header column widths

Fixed header column widths

g1pg1p Posts: 5Questions: 0Answers: 0
edited July 2013 in DataTables 1.9
Hi Allan,

I'm having inordinate amounts of difficulty getting Fixed Headers to set proper widths. I have spent a day poring over the forums and trying different things. No amount of trying will make the header respect the table column widths. I am calling fnAdjustColumnSizing(). I've tried setting styles manually and in code. Nothing will override the widths set on the elements. I've tried everything I can think of and several things I found here. No luck. I've created a log-in for you in our application (give it 15mins) so you can see the problem. I'll provide the details via PM. If you go into Analytics and look at the table on the main All Traffic page, you'll see the problem. I'm dynamically adding summary rows to the header and footer of this one, which makes things much more difficult I might add, but the problem remains without them. If you then look at Products& Orders, you'll see that those tables have fixed headers but no summary rows...and the same problem. You will also see that the fixed header widths are wrong if you scroll over to the far right. Finally, on the All Traffic table, if you remove styling on the top summary rows you will see that the row for 11/7 is underneath the header, so it's not even respecting the width and height. I'm at a loss to know what to do. Any advice will be appreciated. I'm using the latest nightly of Fixed Headers and Datatables 1.9.4.

I was also disappointed to find that Fixed Headers isn't compatible with scrolling. That's a major limitation. Is it likely to be fixed in the next release?

Many Thanks,

Gary.

Replies

  • g1pg1p Posts: 5Questions: 0Answers: 0
    I meant to add that I have also tried setting fixed width columns but sWidth doesn't work in either aoColumns or aoColumnDefs.
  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    > I was also disappointed to find that Fixed Headers isn't compatible with scrolling. That's a major limitation. Is it likely to be fixed in the next release?

    I don't really see the benefit of using FixedHeader and scrolling at the same time - aren't they basically trying to solve the same thing - the table headers being made more visible? The scrolling case works because the scrolling viewport is typically less than the browser.

    It could be fixed in a future release, but its not currently a priority.

    Regarding the actual alignment issue - I wonder if it is related to the total rows. Can you remove them from the main table and see if that helps at all? Is there Javascript updating them or something else? You might need to call the fnUpdate API method if you aren't already (I can't actually see where the DT initialisation is - it looks like you have a shim layer on top of it?).

    Allan
  • g1pg1p Posts: 5Questions: 0Answers: 0
    Hi,

    Thanks for looking. I'm referring to horizontal scrolling, obviously.

    Re: the columns. The tables are built via a jQuery plugin which uses a template. I'm inserting those rows into the header and footer as the table is created. No shim but lots of internal code, yes. I hadn't seen fnUpdate but I don't see how that can update headers or footers. I've already tried all the permutations of removing things that I can think of. Even removing any hint of the header rows doesn't result in properly aligned header columns. I retried for posterity. Nothing changed. Removing fixed headers restores things to their rightful state.

    I had the tables working nicely, with summary rows, before trying to add the fixed headers, using horizontal scrolling. It's only been problematic since.

    I'm still stumped.

    Thanks.
  • g1pg1p Posts: 5Questions: 0Answers: 0
    After spending many hours struggling with this I have made some progress. Firstly, I found that the nightly build I am using has issues. It breaks column widths on all of my table headers. Finally reverting to V2.0.6 recovered them on most of the tables. The one with summary rows was still a problem. I wrote some additional code to set the header table width after rendering, as that was never right. After getting that working perfectly in FF I tested in IE, Chrome, Opera and Safari and found that the header column widths are out by a few pixels in all of them. So, even after all of that work there are serious issues. Even though the header table width is correct, the columns creep by a few pixels and the result is unacceptable. I think probably that this plug-in is not production-ready. A great shame. What we really need is the ability to freeze rows properly within the main table, I think.

    I was unable to get fixed column widths working either, when I tried. I had thought that that might work around the sizing issues but it would be far from ideal as our column widths can vary. Either way, we will probably have to live without this now as the amount of development effort doesn't justify the results.

    Cheers.
  • g1pg1p Posts: 5Questions: 0Answers: 0
    I should also mention that I am seeing the bug, reported elsewhere, where the fixed header sometimes appears above and separated from the main table. That's also a major issue, of course.
This discussion has been closed.