How to add JSON data this way
How to add JSON data this way
Fabris
Posts: 7Questions: 4Answers: 0
I have JSON data in a personalized way, the ID in this case is not merged with the name of the string.
Is it possibile to add this kind of JSON in a simple Datatables grid?
If this is possibile, can I order them using LastName (Last1, 2, 3)?
My JSON:
{"12":{"date_read":"29/07/2022","name_user":"First1 Last1"},
"15":{"date_read":"01/08/2022","name_user":"First2 Last2"},
"22":{"date_read":"15/07/2022","name_user":"First3 Last3"}}
Answers
Not as it stands, as the keys are unique for each record - DataTables needs objects to be consistent. You could however convert that object into an array fairly easy in
ajax.dataSrc
(if it's coming from ajax), or just manipulate it before passing to the DataTables initialisation.Colin