Dinamic table headers
Dinamic table headers
Link to test case: Dont have
Debugger code (debug.datatables.net):
Error messages shown: Dont have any error
Description of problem:
Hi, im new to editor and datables and what i want to this is this:
I have one table that only has dates, i have a form where the user select the first date and the last date and my goal is to generate a table with that days as table headers, can someone help me? Im tired of reading examples and documentation and i dont find nothing with dinamic html column headers
Answers
You wouldn't find anything in the documentation about it as there isn't a way to dynamically add and remove columns from a DataTable. You could update the text in the header cells (
column().header()
) and also combine that with column visibility (column().visible()
) to create the effect of dynamic columns (.e.g if the max needed is 31).Allan
So let me se if i understand it right, i need to define the number of headers? I cant increment that number?
You could do something similar to this example:
http://live.datatables.net/huyexejo/1/edit
It builds the
columns
before initializing Datatables. It usescolumns.title
to define the headers.If you need to change the configuration of a Datatable then you need to use
destroy()
and re-initialize with the new options.Kevin