我正试图找出一种方法来提取用户故事可能具有的附件的链接,但我还没弄清楚如何。就像我拥有的那样,当用户故事有附件时,我在该列中唯一得到的是“[object Object]”。
似乎没有太多关于抓住附件的事情,如果任何人可以摆脱任何光线或指向正确的方向,我一定会感激它!
<html>
<head>
<title>Table</title>
<meta name="Name" content="App Example: Table" />
<meta name="Version" content="2010.4" />
<meta name="Vendor" content="Rally Software" />
<script type="text/javascript" src="https://rally1.rallydev.com/apps/1.24/sdk.js?loginKey=bignumber"></script>
<script type="text/javascript">
function tableExample() {
var rallyDataSource = new rally.sdk.data.RallyDataSource('12345', '12345', 'True', 'True');
function itemQuery() {
var queryObject = {
key: 'stories',
type: 'HierarchicalRequirement',
fetch: 'FormattedID,Name,ScheduleState,Description,Attachments',
query: '(Name contains "release")'
};
rallyDataSource.findAll(queryObject, populateTable);
}
function populateTable(results) {
var tableDiv = document.getElementById('aDiv');
var config = { columns:
[{key: 'FormattedID', header: 'Formatted ID', width: 100},
{key: 'Name', width: 400},
{key: 'ScheduleState', header: 'Schedule State', width: 200},
{key: 'Description', width: 800},
{key: 'Attachments', header: 'Attachment Link', width: 200}]};
var table = new rally.sdk.ui.Table(config);
table.addRows(results.stories);
table.display(tableDiv);
};
itemQuery();
}
rally.addOnLoad(tableExample);
</script>
</head>
<body>
<div id="aDiv"></div>
</body>
</html>
答案 0 :(得分:1)
我包含了一个稍微修改过的App示例版本,它会进行一些后期处理以提取每个附件的对象ID并将其放入一些HTML链接中,这些链接会更新到相关的表格列中。
<html>
<head>
<title>Table</title>
<meta name="Name" content="App Example: Stories with Attachments" />
<meta name="Version" content="2010.4" />
<meta name="Vendor" content="Rally Software" />
<script type="text/javascript" src="https://rally1.rallydev.com/apps/1.29/sdk.js"></script>
<script type="text/javascript">
var table = null;
function tableExample() {
var rallyDataSource = new rally.sdk.data.RallyDataSource('__WORKSPACE_OID__',
'__PROJECT_OID__',
'__PROJECT_SCOPING_UP__',
'__PROJECT_SCOPING_DOWN__');
function itemQuery() {
var queryObject = {
key: 'stories',
type: 'HierarchicalRequirement',
fetch: 'FormattedID,Name,ScheduleState,Description,Attachments,ObjectID'
// query: '(Name contains "release")'
};
rallyDataSource.findAll(queryObject, populateTable);
}
function populateTable(results) {
if (table) {
table.destroy();
}
var tableDiv = document.getElementById('aDiv');
var config = { 'columnKeys' : ['FormattedID', 'Name', 'ScheduleState', 'Attachments'],
'columnHeaders' : ['FormattedID', 'Name', 'ScheduleState', 'Attachments'],
'columnWidths' : ['100px', '400px', '85px', '300px']
};
table = new rally.sdk.ui.Table(config);
table.addRows(results.stories);
for (i=0;i<results.stories.length;i++) {
myStory = results.stories[i];
myAttachments = results.stories[i].Attachments;
myAttachmentHTML = "";
for (j=0;j<myAttachments.length;j++) {
myAttachmentOID = myAttachments[j].ObjectID;
myAttachmentName = myAttachments[j].Name;
myAttachmentURL = "https://rally1.rallydev.com/slm/attachment/"+
myAttachmentOID + "/" + myAttachmentName;
myAttachmentHTML += "<div><a href='" + myAttachmentURL + "'>" +
myAttachmentName + "</a></div>";
}
table.setCell(i, 3, myAttachmentHTML);
}
table.display(tableDiv);
};
itemQuery();
}
rally.addOnLoad(tableExample);
</script>
</head>
<body>
<div id="aDiv"></div>
</body>
</html>