<table class="confluenceTable", id="projectListTable">
<tr>
<th class="confluenceTh" >Key</th>
<th class="confluenceTh" >Name</th>
<th class="confluenceTh" >Lead</th>
</tr>
</table>
<script>
$.ajax({
url: confluence/plugins/servlet/applinks/proxy?appId=ID&path=jira/rest/api/2/project?expand=lead',
type: "get",
dataType: "json",
success: function(project) {
drawTable(project);
}
});
function drawTable(project) {
for (var i = 0; i < project.length; i++) {
drawProjectRow(project[i]);
}
}
function drawProjectRow(rowProject) {
var row = $("<tr/>")
$("#projectListTable").append(row);
row.append($("<td class=\"confluenceTd\" >" + rowProject.key + "</td>"));
row.append($("<td class=\"confluenceTd\" >" + rowProject.name + "</td>"));
row.append($("<td class=\"confluenceTd\" >" + rowProject.lead[0] + "</td>"));
}
</script>
Hi i'm trying to create dynamic table.
In column Lead getting "undefined"
And tell me how to make a link to the project from the key =)
Hi @Alex ,
I believe lead is not an array but it is JSON object with key, name and displayName fields. So you need to use not rowProject.lead[0] but e.g. rowProject.lead.displayName instead.
To make a link you just need to concatenate your base url with project key to get something like
<a href="http://localhost:8230/projects/rowProject.key">rowProject.name</a>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.