How to initialize a datatables without columns
How to initialize a datatables without columns
ebagaipo
Posts: 13Questions: 5Answers: 0
hi,
How to initialize a datatables without columns?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi @ebagaipo ,
There's an existential query - can a table be a table if it has no columns? I suspect a lot of the code makes the assumption that that's the case.
Cheers,
Colin
The columns on my table are dynamic. So I need to initialize (I think this is a must?) datatables then get the columns and data then put to the datatables.
You would use
columns.title
to have Datatables create the columns. You can fetch thee column info from ajax. This example derives the column names from the field names of the first row of data. You could use a dedicated object to provide the column info.http://live.datatables.net/huyexejo/1/edit
Kevin
This is I get:
Expected the request to have a sEcho value greater than 0
The biggest issue is that with server side processing enabled you also need to use the
ajax
option. See this thread:https://datatables.net/forums/discussion/comment/148524/#Comment_148524
My suggestion would be to use the jQuery ajax request to get the column info then in the success build the table headers followed by initializing Datatables with serversid eprocessing and with the
ajax
option. Or disable serverside processing.Kevin
I disabled serverside processing but no data display
It is working now by setting serverside = false.
It is working now by setting serverside = false with minor changes on my code.