Is it possible to have datatables accept json in a column?
Is it possible to have datatables accept json in a column?
max_favilli
Posts: 4Questions: 0Answers: 0
I have a table with 20 columns where at the end I just make 2 columns visible with dynamically crafted html during "fnRender", I use the other 18 columns content to build the html using "o.aData[n]" inside the "fnRender".
I was wondering, can't I return a structured JSON object as column 0 and just use it in fnRender for column 1 and 2, avoiding to return 20 columns?
I know it's still JSON and it's not going to change much in terms of bandwidth but at least I don't have to put useless html markup in the page, and I can have a more simple aoColumns array.
Is it possible?
I was wondering, can't I return a structured JSON object as column 0 and just use it in fnRender for column 1 and 2, avoiding to return 20 columns?
I know it's still JSON and it's not going to change much in terms of bandwidth but at least I don't have to put useless html markup in the page, and I can have a more simple aoColumns array.
Is it possible?
This discussion has been closed.
Replies
I've never tired it, but I don't see any reason why that wouldn't work :-)
Allan
I endedup doing the following:
[code]
"fnServerData": function (sSource, aoData, fnCallback) {
jQuery.ajax({
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": function (a, b, c) {
_t.slug = a.bbData;
delete a.bbData;
fnCallback(a,b,c);
}
});
},
[/code]
I send all the data I require for formatting as new proprty bbData and remove it before to pass it to fnCallback, I store bbData in an array within the class and since bbData and aaData have the same lenght and are sorted the same I just read it using the index in my "fnRender" functions.
Hope it help others.
Thanks for the support.
Max