Rally App SDK:有没有办法为表设置变量列? [英] Rally App SDK: Is there a way to have variable columns for table?
问题描述
使用 Rally App SDK,有没有办法创建一个列数可变的表?例如,对于选定的版本,列是该发布日期范围内的迭代,行是每个项目.
我有想要显示的所有数据,但不确定如何创建表格.
这是一个示例应用程序,它以迭代名称作为列动态构建表配置,然后向其中添加一些虚拟数据.不太令人兴奋,但它说明了这个想法.
<!-- 版权所有 (c) 2002-2011 Rally Software Development Corp.保留所有权利.--><头><title>作为表列的迭代</title><meta name="Name" content="App: Iterations as Table Columns"/><script type="text/javascript" src="https://rally1.rallydev.com/apps/1.29/sdk.js"></script><script type="text/javascript">函数迭代AsTableColumns(rallyDataSource){var 等待 = 空;无功表=空;var tableHolder = null;//私有方法构建迭代列和您的信息表功能显示结果(结果){如果(等待){等待.隐藏();等待=空;}如果(表){table.destroy();}var myIterations = results.iterations;如果(myIterations.length === 0){tableHolder.innerHTML = "没有找到迭代";返回;}var columnKeys = new Array();var columnHeaders = new Array();var columnWidths = new Array();var columnWidthValue = '80px';var keyName;//为表配置动态构建列配置数组for (i=0; i<script type="text/javascript">集会.addOnLoad(函数(){var 拉力数据源 = 新拉力.sdk.data.RallyDataSource('__WORKSPACE_OID__','__PROJECT_OID__','__PROJECT_SCOPING_UP__','__PROJECT_SCOPING_DOWN__');var 迭代AsTableColumnsExample = 新的迭代AsTableColumns(rallyDataSource);迭代AsTableColumnsExample.display();});头部><身体><div><span id="buttonSpan"></span>
<div style="height: 15px;"> </div><div id="table"></div></html>
Using the Rally App SDK, is there a way to create a table with a variable number of columns? For example, for a selected release, the columns are the iterations within that release date range, and the rows are each project.
I have all of the data I want to display, but not sure how to create the table.
Here's an example app that dynamically builds a table config with Iteration Names as columns and then adds some dummy data to it. Not too exciting, but it illustrates the idea.
<!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>
<title>Iterations as Table Columns</title>
<meta name="Name" content="App: Iterations as Table Columns"/>
<script type="text/javascript" src="https://rally1.rallydev.com/apps/1.29/sdk.js"></script>
<script type="text/javascript">
function iterationsAsTableColumns(rallyDataSource)
{
var wait = null;
var table = null;
var tableHolder = null;
// private method the builds the table of Iteration columns and your info
function showResults(results)
{
if (wait) {
wait.hide();
wait = null;
}
if (table) {
table.destroy();
}
var myIterations = results.iterations;
if (myIterations.length === 0) {
tableHolder.innerHTML = "No iterations were found";
return;
}
var columnKeys = new Array();
var columnHeaders = new Array();
var columnWidths = new Array();
var columnWidthValue = '80px';
var keyName;
// Dynamically build column config arrays for table config
for (i=0; i<myIterations.length;i++){
keyName = "Column"+i;
columnKeys.push(keyName);
columnHeaders.push("'" + myIterations[i].Name + "'");
columnWidths.push("'" + columnWidthValue + "'");
}
var config = { 'columnKeys' : columnKeys,
'columnHeaders' : columnHeaders,
'columnWidths' : columnWidths
};
table = new rally.sdk.ui.Table(config);
var cellValue;
var propertyAttributeStatement;
var rowData = new Array();
for (i=0;i<10;i++){
// create Object for row data
rowItem = new Object();
for (j=0; j<columnKeys.length;j++){
cellValue = "Cell[" + i + "][" + j + "] = Your Data Here";
propertyAttributeStatement = "rowItem." + columnKeys[j] + " = '"+cellValue+"';";
eval(propertyAttributeStatement);
}
rowData.push(rowItem);
}
table.addRows(rowData);
table.display(tableHolder);
}
//private method to query for iterations that get listed as columns
function runMainQuery(sender, eventArgs) {
var queryCriteria = '(Project.Name = "Avalanche Hazard Mapping"")';
var queryConfig =
{
key : "iterations",
type : "Iteration",
fetch : "FormattedID,Name,Project,StartDate,EndDate,CreationDate",
order : "CreationDate desc",
};
tableHolder.innerHTML = "";
wait = new rally.sdk.ui.basic.Wait({});
wait.display(tableHolder);
rallyDataSource.findAll(queryConfig, showResults);
}
//private method to start building controls on page
function initPage() {
buttonSpan = document.getElementById('buttonSpan');
tableHolder = document.getElementById('table');
var buttonConfig = {
text: "Show Table",
value: "myValue"
};
var showTableButton = new rally.sdk.ui.basic.Button(buttonConfig);
showTableButton.display(buttonSpan, runMainQuery);
}
// only public method
this.display = function() {
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 iterationsAsTableColumnsExample = new iterationsAsTableColumns(rallyDataSource);
iterationsAsTableColumnsExample.display();
});
</script>
</head>
<body>
<div>
<span id="buttonSpan"></span>
</div>
<div style="height: 15px;"> </div>
<div id="table"></div>
</body>
</html>
这篇关于Rally App SDK:有没有办法为表设置变量列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!