Columns.data format for this particular scenario
Columns.data format for this particular scenario
mirfilip
Posts: 2Questions: 1Answers: 0
Hi,
I am trying to consume such an API response:
{
"data":
{
"a":
{"b": 1},
"c":
{"d": 2}
}
}
I would like to display it as :
| Some Name | Other Name | Count |
-----------------------------------------------
| a | b | 1 |
| c | d | 2 |
Note that "a", "b", "c", "d" are not the constant keys, they are variable. I know that "dataSrc": "data" is the must here but I am unable to parse the nested object. Any advice ?
This discussion has been closed.
Answers
The formatting has been stripped. I would want to show two records: (a, b, 1) and (c, d, 2)
You would need to reformat the data into an array. DataTables currently does not support using objects as a data source for the whole table, only for individual rows. You must use an array, with one entry for each row in the table.
Allan