javascript - How to parse json into html table? -
i want parse json data html table int format of :
project title eac bac overrun percentage project1 0 day 0 day 0 15% closed 18/07/2016-18/08/2017 project 2 350 day 15 day 15 30% closed 05/02/2016-12/09/2022 i found answer parsing json objects html table used write code:
$.ajax(settings).done(function (result) { var str = json.stringify(result); obj = json.parse(str); for(var = 0; < obj.value.length; i++) { tr = $('<tr/>'); tr.append("<td class=\"project_title\">" + obj.value[i].name + "</td>" + "<td class=\"project_title\">" + obj.value[i].eac + "</td>" + "<td class=\"project_title\">" + obj.value[i].bac + "</td>" + "<td class=\"project_title\">" + obj.value[i].overrun + "<td class=\"project_title\">" + obj.value[i].percentage + "</td>"); $('table').append(tr); } }); but didn't understand how add status of project , date in same cell on project title. example project 1 should add such status closed , date of begin , end of project 18/07/2016-18/08/2017. how can add these options each project?
just add </br> between fields want in first cell:
tr.append("<td class=\"project_title\">" + obj.value[i].name + "</br>" + obj.value[i].attribute1 + "</br>" + obj.value[i].attribute2 + "</td>"); it may work in case.
Comments
Post a Comment