What is the best way to create columns? Probs with column resizing.
What is the best way to create columns? Probs with column resizing.
It seems if you start with a blank HTML and create the columns with aoColumns, datatables.net then creates two underlying for you. It seems like this is a PITA to keep the table fluid with column resizing. All the time our header table doesn't resize, when the data table does.
Also, I have a feeling this is probably why user column reorder/resizing plugins don't work.
Yes, I'm aware of fnColumnAdjustSizing, but it is a pain to use and not always perfect.
>>>Can I do what I'm proposing below, and would it clear up some of the issues above?
Start with a plain empty . Then dynamically JavaScript add my own with the columns (but no or data). Then initialize that table like normal?
It would appear from the examples that just the one underlying table is used, and might clear up some problems.
If this does indeed work, then why doesn't datatables.net just do that? I really don't get the need for the two tables. Unless it is to add a vertical scroll bar or something.
Also, I have a feeling this is probably why user column reorder/resizing plugins don't work.
Yes, I'm aware of fnColumnAdjustSizing, but it is a pain to use and not always perfect.
>>>Can I do what I'm proposing below, and would it clear up some of the issues above?
Start with a plain empty . Then dynamically JavaScript add my own with the columns (but no or data). Then initialize that table like normal?
It would appear from the examples that just the one underlying table is used, and might clear up some problems.
If this does indeed work, then why doesn't datatables.net just do that? I really don't get the need for the two tables. Unless it is to add a vertical scroll bar or something.
This discussion has been closed.
Replies
If you have scrolling enabled then yes. If not - then no - your table node is used. Two tables are used when scrolling is enabled because it is necessary to put the body into its own scrolling DIV container to give the scrolling interface. Cross browser TBODY scrolling is just not possible. And yes - this is a massive PITA. I've spent countless hours getting this to a point where it works 99% of the time, and there is always the odd case that breaks it!
Without scrolling we can do something like this: http://datatables.net/release-datatables/examples/basic_init/flexible_width.html . With scrolling, you _must_ use fnColumnAdjustSizing to let DataTables adjust the columns for the new layout if you change the container width.
> Start with a plain empty . Then dynamically JavaScript add my own with the columns (but no or data). Then initialize that table like normal?
Yes that is perfectly possible, but as I say, you need to consider if you are using scrolling or not and the effect that has.
Allan
Thanks for the clarification.