using deep nested data in child rows?
using deep nested data in child rows?
indymx
Posts: 63Questions: 3Answers: 0
is this possible?
My data looks like this:
[code]
{
"data": [
{
"id": 30,
"customer": "Customer 3",
"shipper": "Company 2",
"consignee": "Company 3",
"tracking": "L353110",
"carrier": "Carrier 2",
"carrierPro": "327229",
"pickupTime": "02-28 23:02",
"deliveryTime": "02-21 07:02",
"nextUpdate": "03-02 14:03",
"status": "Scheduled",
"sendto": "terryg",
"contact": "dispatch / 555-555-1234",
"comments": [
{
"id": 62,
"load_id": 30,
"comment": "Delivered",
"update_time": null,
"updated_by": "terryg",
"miles": "123",
"localeta": "2014-02-12 18:00:27",
"location": "Columbus, OH"
}
]
}
]
}
[/code]
I've tried everything I can find on here as far as examples go to get this working. To no avail.
I'm building the child rows like you show in :
http://next.datatables.net/examples/api/row_details.html
I tried adding the lines that I'm having trouble with like this:
[code]
function format ( d ) {
// `d` is the original data object for the row
return ''+
''+
'Carrier'+
''+d.carrier+''+
'Contact'+
''+d.contact+''+
'Track / LID'+
''+d.tracking+''+
'Carrier Pro'+
''+d.carrierPro+''+
''+
''+
'Shipper'+
''+d.shipper+''+
'Consignee'+
''+d.consignee+''+
'Send Updates To'+
''+d.sendto+''+
' '+
''+d.update+''+
''+
''+
''+d.comments.location+''+
''+d.comments.comment+''+
''+d.comments.miles+''+
''+d.comments.localeta+''+
''+
''+
'Location'+
''+
'Miles Out'+
''+
'Local ETA'+
''+
'Comments'+
''+
''+
'';
}
[/code]
if I change the "d.comments.location" variable to "d.comments.0.location"
I get "Unexpected number".. leave out the 0 and I get "undefined"..
I'm really not clear on how I can get this json data displaying.
My data looks like this:
[code]
{
"data": [
{
"id": 30,
"customer": "Customer 3",
"shipper": "Company 2",
"consignee": "Company 3",
"tracking": "L353110",
"carrier": "Carrier 2",
"carrierPro": "327229",
"pickupTime": "02-28 23:02",
"deliveryTime": "02-21 07:02",
"nextUpdate": "03-02 14:03",
"status": "Scheduled",
"sendto": "terryg",
"contact": "dispatch / 555-555-1234",
"comments": [
{
"id": 62,
"load_id": 30,
"comment": "Delivered",
"update_time": null,
"updated_by": "terryg",
"miles": "123",
"localeta": "2014-02-12 18:00:27",
"location": "Columbus, OH"
}
]
}
]
}
[/code]
I've tried everything I can find on here as far as examples go to get this working. To no avail.
I'm building the child rows like you show in :
http://next.datatables.net/examples/api/row_details.html
I tried adding the lines that I'm having trouble with like this:
[code]
function format ( d ) {
// `d` is the original data object for the row
return ''+
''+
'Carrier'+
''+d.carrier+''+
'Contact'+
''+d.contact+''+
'Track / LID'+
''+d.tracking+''+
'Carrier Pro'+
''+d.carrierPro+''+
''+
''+
'Shipper'+
''+d.shipper+''+
'Consignee'+
''+d.consignee+''+
'Send Updates To'+
''+d.sendto+''+
' '+
''+d.update+''+
''+
''+
''+d.comments.location+''+
''+d.comments.comment+''+
''+d.comments.miles+''+
''+d.comments.localeta+''+
''+
''+
'Location'+
''+
'Miles Out'+
''+
'Local ETA'+
''+
'Comments'+
''+
''+
'';
}
[/code]
if I change the "d.comments.location" variable to "d.comments.0.location"
I get "Unexpected number".. leave out the 0 and I get "undefined"..
I'm really not clear on how I can get this json data displaying.
This discussion has been closed.
Replies
Allan
now to just loop thru that array and get all the data from it in the table.. (scratching head more)
Thanks again for nudging me in the right direction here..
[code]
for (var i=0,len=d.comments.length; i