Concatenate nested object in single column
Concatenate nested object in single column
This is json:
[{
"film": "The Avengers",
"genre": "Action",
"date": {
"year": 2016,
"month": 2,
"day": 11
},
"localTime": {
"time": {
"hour": 17,
"minute": 57,
"second": 0,
"nano": 0
}
},
"ticketNumber": 1,
"price": 8.5
}]
Here there are html and javascript and json indented(in javascript area): https://jsfiddle.net/vyrydr2b/4/
Hi, how i can concatenate, in a single column "Date", the three values date.year, date.month, date.day to create something like 2016/2/11? Also, how can i concatenate, in a single column "Time", the two values localTime.time.hour, localTime.time.minute to create something like 17:57?
Sorry for my bad english :(
Thank you in advance
Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Answers
You are loading data in object form, so that makes it easy. Take a look at
columns.render
.See https://jsfiddle.net/w2qtjo2j/ . I'm getting an ajax error from the fiddle, but I think the syntax is correct or at least close
You may also need to use
ajax.dataSrc
set to be an empty string if you are just returning an array of objects, rather than an object with adata
property.Allan