Fill table with header from file
Fill table with header from file
delphi10
Posts: 17Questions: 8Answers: 0
I try fill to dinamic my blank table without header (th). Define columns in my file.
My version (success) not working? Wrong define columns in file?
My Txt:
{
"columns": [
[ "N" ],[ "User" ],[ "Age" ]
],
"data": [
["1","Jack","31"],
["2","Smith","29"]
]
}
My JS:
var table = $('#example').DataTable({
"processing": true,
"ajax": {
"url": file,
"type": "POST",
"dataType": "json",
"success": function(json) {
var header;
$.each(json.columns, function(i, item){
header += "<th>" + item + "</th>";
}
$("#example>thead>tr").append(header);
}
},
"deferRender": true,
"lengthChange": false,
"bInfo" : true,
"retrieve": true,
"pageLength": 10
});
Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This discussion has been closed.
Answers
Hi,
This FAQ covers what you are looking to do.
Allan