我有一个代码片段(自定义Rally App)来列出所有重新打开的缺陷。我认为除了一个小故障外,它的工作正常。该表有空白行。像这样 - 我的代码是 -
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http:/...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!-- Copyright (c) 2002-2011 Rally Software Development Corp. All rights reserved. -->
<html>
<head>
<meta name="Name" content="App: Defects by Closer"/>
<meta name="Version" content="2012.01.14"/>
<meta name="Vendor" content="Rally Software"/>
<script type="text/javascript" src="/apps/1.33/sdk.js?apiVersion=1.29"></script>
<script type="text/javascript">
/*
Copyright (c) 2002-2011 Rally Software Development Corp. All rights reserved.
DefectsByCloser.js
*/
function DefectsByCloser(rallyDataSource) {
var releaseDiv, tableDiv;
var releaseDropdown;
var table;
var wait = null;
// private method the builds the table of defects and associated info
function showResults(results) {
if (wait) {
wait.hide();
wait = null;
}
if (results.defects.length === 0) {
tableDiv.innerHTML = "No relevant defects associated with the selected release were found";
return;
}
var config =
{ 'columnKeys' : ['FormattedID' , 'Name', 'State', 'Revision Number', 'ClosedBy', 'Description' ] ,
'columnHeaders': ['Formatted ID', 'Name', 'Status', 'Revision<br>Number', 'Closed By', 'Description' ] ,
'columnWidths' : ['80px', '360px', '60px', '60px', '120px' , '500px' ]
};
table = new rally.sdk.ui.Table(config);
var linkConfig = null;
var defectLink = null;
var cd = null; // for defect.ClosedDate formatting
var i, j, defect;
for (i = 0; i < results.defects.length; i++) {
defect = results.defects[i];
//create link to defect
linkConfig = {item: {FormattedID: defect.FormattedID, "_ref" : defect._ref}};
defectLink = new rally.sdk.ui.basic.Link(linkConfig);
for (j = 0; j < defect.RevisionHistory.Revisions.length; j++) {
var revision = defect.RevisionHistory.Revisions[j];
var defectName = defect.Name + '';
if (revision.Description.search("Unresolved") !== -1 && defectName.trim() != '') {
console.log('defectName:' + defectName);
table.setCell(i, 0, defectLink.renderToHtml());
table.setCell(i, 1, defect.Name);
table.setCell(i, 2, defect.State);
table.setCell(i, 3, '' + revision.RevisionNumber);
table.setCell(i, 4, '' + revision.User._refObjectName);
table.setCell(i, 5, '' + revision.Description);
break; //only show the most recent result if defect was reopened/reclosed
}
}
}
//console.log(tableDiv);
table.display(tableDiv);
}
//private method to query for defects when release selection changes
function runMainQuery() {
if (table) {
table.destroy();
table = null;
}
tableDiv.innerHTML = "";
var queryConfig =
{
key : "defects",
type : "Defect",
fetch : "ObjectID,FormattedID,Name,ClosedDate,RevisionHistory,Revisions,RevisionNumber,Description,User",
order : "FormattedID",
};
wait = new rally.sdk.ui.basic.Wait({});
wait.display('wait');
rallyDataSource.findAll(queryConfig, showResults);
}
//private method to start building controls on page
//page consists of a dropdown to select the release and the table to hold the query results
function initPage() {
tableDiv = document.getElementById('table');
runMainQuery();
}
// only public method
this.display = function() {
rally.sdk.ui.AppHeader.setHelpTopic("232");
rally.sdk.ui.AppHeader.showPageTools(true);
initPage();
};
}
</script>
<script type="text/javascript">
rally.addOnLoad(function() {
var rallyDataSource = new rally.sdk.data.RallyDataSource('__WORKSPACE_OID__',
'__PROJECT_OID__',
'__PROJECT_SCOPING_UP__',
'__PROJECT_SCOPING_DOWN__');
var defectsByCloser = new DefectsByCloser(rallyDataSource);
defectsByCloser.display();
});
</script>
</head>
<body>
<div id="release" style="float:left"></div>
<div id="wait" style="float:left; height: 16px; width: 24px;"></div>
<div id="table" style="clear:both;padding-top:15px"></div>
</body>
</html>
免责声明:我对Javascript和Rally App SDK的了解有限。请帮我解决这个问题。
答案 0 :(得分:0)
此应用程序是使用已弃用的App SDK 1.x编写的,因此我承认我不是此处的专家。但我的预感是你的数据格式不正确 - 或者至少它的格式与你构建表格内容的循环所期望的格式不同。
我尝试设置一些调试语句,控制在该区域中记录事物以查看数据为何没有达到预期的形状。另一个可能的问题是你可能没有在RallyDataSource.findAll中获取所需的所有字段吗?