FixedHeader column width not correct

FixedHeader column width not correct

burncharburnchar Posts: 118Questions: 12Answers: 0
edited September 2013 in FixedHeader
I was having trouble with the FixedHeader plugin and AJAX data.
The problem was that the FixedHeader examples have the FixedHeader plugin load immediately after the DataTable object is finished initializing, but also before the AJAX data is loaded. Once the AJAX data came in, the columns would resize, but the headers would not.

I found a number of proposed solutions on StackOverflow, but they all seemed bizarrely complex and limiting.

I found a simple solution and thought I'd share it, though it will be no huge revelation for those familiar with the API:

[code] "fnInitComplete": function(settings, json) {
new FixedHeader(dataTableObject);

},
// ... more DT init code[/code]

The solution is to put your FixedHeader call within fnInitComplete.

This works for my application because the data table is created with each data search, but for applications which never re-create the DataTable, you may need to call FixedHeader's fnUpdate() within a callback which is called more often, like fnHeaderCallback(). I haven't tested the latter.
This discussion has been closed.