I have data from an AJAX request in the format:
{
81920: {
1: ['David Johnson'],
2: ['Jarvis Landry', 'Mark Ingram']
},
38913: {
1: ['Julio Jones', 'T.Y. Hilton', 'Jordan Howard'],
2: ['David Johnson']
}
And I want to display it in a table, like (empty cells left blank):
Side 1 | Side 2
-----------------------------
David Johnson | Jarvis Landry
(empty cell) | Mark Ingram
-----------------------------
Julio Jones | David Johnson
T.Y. Hilton | (empty cell)
Jordan Howard | (empty cell)
-----------------------------
I initialize the datatable with:
var trade_table;
trade_table = $('#trades').dataTable( {
columns: [
{ title: "team1 gave" },
{ title: "team2 gave"}
],
paging: false,
info: false
} );
And I want try to update it after my AJAX request with:
success: function(response) {
// clear table and add new data
$('#trades').dataTable().fnClearTable();
$('#trades').dataTable().fnAddData(response);
}
I can change the format of the data if needed to use just a list instead of a JSON, or some other format. Thanks!