How to display mjoin array results (2 fields) concatenated in table
How to display mjoin array results (2 fields) concatenated in table
I am retrieving "building_name" and "area_name" through a mjoin with linked table (one ID retrieves two fields - the building and the area in the building)
I can display the array results as either:
{ data: "building_areas",
render: "[, ].building_name"
},
or
{ data: "building_areas",
render: "[, ].building_name"
},
but what I need is something like:
{ data: "building_areas",
render: "[, ].building_name" + [].area_name
},
I'm sure I'm just not getting the syntax right, but I've tried a few dozen combinations.
Can anyone offer a solution?
Thank you!
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Sorry - that second block of code should be:
Just to clarify:...
This is what is returned from JSON
"building_areas":[{"area_id":"116","building_name":"Emergency","area_name":null},{"area_id":"686","building_name":"SMH","area_name":"1st Floor"},{"area_id":"756","building_name":"SMH","area_name":"2nd Floor"},
{"area_id":"811","building_name":"SMD","area_name":"3000"}]
and what I would like to display in one table cell of the table is
Emergency, SMH 1st Floor, SMH 2nd Floor, SMD 3000
I'm sure I'm just javascript challenged...
Any help is much appreciated.
See if this example helps:
http://live.datatables.net/kolomujo/1/edit
basically it loops through each element in the array to build a string to display. Looks like you can do something similar with your data.
Kevin
Kevin Thank You So Much!!
Works perfectly and I am very grateful for your help!
-Brenda