JSON to table

1008
2
Jump to solution
06-11-2013 09:34 AM
JacobKohute
New Contributor II
I was wondering if anyone has had any success implementing a json to html table before. I currently have an SOE that does a geometric network trace and returns all the attributes of connected features, then draws the graphics on the map. I'd like to implement a way for users to display the attributes of connected features but have been unable to get it running. I'm using Javascript since I need this website to be usable on multiple platforms.
0 Kudos
1 Solution

Accepted Solutions
LukePhilips
New Contributor III
You will have to iterate over your JSON data and build a table, e.g. if you did this in pure html:
var html = ""; html += "<table border='1' width='100%'><tr><th>headerColumn1</th><th>headerColumn2</th></tr>"; for (var i = 0, il = mydata.length; i < il; i++) {     html += "<tr><td>" + mydata.elementA + "</td>";     html += "<td>" + mydata.elementB  + "</td>"; } html += "</tr></table>";

then the html could be added as the content to an infoWindow.

a more complicated example, using a dojo grid:
http://developers.arcgis.com/en/javascript/jssamples/fl_paging.html

View solution in original post

0 Kudos
2 Replies
LukePhilips
New Contributor III
You will have to iterate over your JSON data and build a table, e.g. if you did this in pure html:
var html = ""; html += "<table border='1' width='100%'><tr><th>headerColumn1</th><th>headerColumn2</th></tr>"; for (var i = 0, il = mydata.length; i < il; i++) {     html += "<tr><td>" + mydata.elementA + "</td>";     html += "<td>" + mydata.elementB  + "</td>"; } html += "</tr></table>";

then the html could be added as the content to an infoWindow.

a more complicated example, using a dojo grid:
http://developers.arcgis.com/en/javascript/jssamples/fl_paging.html
0 Kudos
JacobKohute
New Contributor II
I think I like the look of the grid better. I'll give that a kick and let you know how it goes. Thanks!
0 Kudos