Constructing a table from an ajaxSource
Constructing a table from an ajaxSource
Hi,
first post here :)
I've been struggling with this issue for 2 days now, and I suspect that I'm missing something crucial and basic. I'm trying to construct a table from an ajax call, the tricky thing is that I don't know which fields I'll be getting, so the table structure is dynamic. By the way, I couldn't find a link on the website saying "documentation", all I could gather is stuff from the examples (which are great, but sometimes not enough).
How should the ajaxSource JSON object be structured so that the whole table (including num of columns, headers etc.) could be derived from it? I couldnt find any info regarding this :(
Thanks :)
first post here :)
I've been struggling with this issue for 2 days now, and I suspect that I'm missing something crucial and basic. I'm trying to construct a table from an ajax call, the tricky thing is that I don't know which fields I'll be getting, so the table structure is dynamic. By the way, I couldn't find a link on the website saying "documentation", all I could gather is stuff from the examples (which are great, but sometimes not enough).
How should the ajaxSource JSON object be structured so that the whole table (including num of columns, headers etc.) could be derived from it? I couldnt find any info regarding this :(
Thanks :)
This discussion has been closed.
Replies
Because it isn't currently, directly possible. Basically you need to make the Ajax call using $.ajax and then construct the table as you need. You can use sTitle to set the title for the columns (i.e. build up aoColumns based on the data returned from the server) - but at this time DataTables doesn't support dynamic addition and deletion of columns. The number of columns you have when you initialise the table is the number for the lifetime of the table.
Allan