1

我已经研究并尝试了所有我能想到的方法来尝试检索迭代、项目和用户列的实际值,但我永远无法获取列数据来填充迭代名称、项目名称等内容,以及用户提交的名称。我已经读过,按照我的方式进行获取应该没问题,其他人说你必须用这样的东西指定类型

types : ['defect','user','iteration','project'],

当我这样做时,我永远不会加载我的网格。我已经按照某些人的建议尝试过这样的事情

defect.Iteration.Name

或者

Iteration.Name

我真的可以在这里使用一些帮助。我还阅读了一篇文章,说 WSAPI 不再支持这种请求,必须在多个查询/获取中进行处理。任何人,这是我正在使用的代码......

function onLoad() {
var rallyDataSource = new rally.sdk.data.RallyDataSource(
                '__WORKSPACE_OID__',
                '__PROJECT_OID__',
                '__PROJECT_SCOPING_UP__',
                '__PROJECT_SCOPING_DOWN__');
var config = {
              type : 'defect',
              key  : 'defects',       
              columnKeys : ["FormattedID", "Name", "Priority125", "Iteration", "Project", "SubmittedBy", "CreationDate", "ScheduleState", "State"],
              fetch : 'FormattedID,Name,Priority125,Iteration,Project,SubmittedBy,CreationDate,ScheduleState,State',
              query : '((State != "Closed") OR (ScheduleState != "Accepted"))',
              order : 'Priority125'
              };
var table = new rally.sdk.ui.Table(config, rallyDataSource);
table.display("tableDiv");
}
rally.addOnLoad(onLoad);
4

1 回答 1

0

为了使它按您的要求工作,需要做几件事:

  1. 您可以递归地获取最高一级的深度。因此,如果您想获取缺陷名称、格式化 ID 和项目名称,您的获取将如下所示:
  2. 获取:“名称,格式化ID,项目,名称”
  3. 通过 rallyDataSource.findAll() 获取数据
  4. 对数据进行后处理,以便为表提供所有字符串数据。即破坏对象引用字段,如项目,而不是项目名称。
  5. 最后,填充并显示表格。

这是一个工作示例,说明了我认为您想要做的事情(减去您定义的“优先级 125”自定义字段)。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- Copyright (c) 2011  Rally Software Development Corp.  All rights reserved -->
<html>
<head>
    <title>Defect Information</title>
    <meta name="Name"    content="Defect Information" />
    <meta name="Version" content="1.32" />
    <meta name="Vendor"  content="Rally Software" />

    <script type="text/javascript" src="https://rally1.rallydev.com/apps/1.32/sdk.js?debug=True"></script>
    <script type="text/javascript">

        var rallyDataSource = null;
        var table = null;

        function showTable(results) {

            if (table) {
                table.destroy();
            }

            var tableConfig = {
                columnKeys   : ["FormattedID", "Name", "Iteration", "Project", "SubmittedBy", "CreationDate", "ScheduleState", "State"],
                columnWidths : ["85px",        "350px", "90px",      "100px",  "100px",       "120px",         "100px",         "100px" ]
            };

           table = new rally.sdk.ui.Table(tableConfig);

            // Loop through the rows and clobber object attributes of the results collection with
            // string values
            for(var i = 0; i < results.defects.length; i++){

                thisDefect = results.defects[i];

                var iterationName = "";
                // Grab value fields
                if (thisDefect.Iteration != null) {
                    iterationName = results.defects[i].Iteration.Name;
                } else {
                    iterationName = "Un-scheduled";
                }
                var projectName = thisDefect.Project.Name;

                // Re-map SubmittedBy object to SubmittedBy string
                submittedByDisplayName = thisDefect.SubmittedBy === null ? "": thisDefect.SubmittedBy._refObjectName;                

                // Clober objects with values
                results.defects[i].Iteration = iterationName;
                results.defects[i].Project = projectName;
                results.defects[i].SubmittedBy = submittedByDisplayName;
            }

            table.addRows(results.defects);
            table.display(document.getElementById('defectsDiv'));
        }


        function onLoad() {
            rallyDataSource = new rally.sdk.data.RallyDataSource(
                    '__WORKSPACE_OID__',
                    '__PROJECT_OID__',
                    '__PROJECT_SCOPING_UP__',
                    '__PROJECT_SCOPING_DOWN__');

            var config = {
              type : 'defect',
              key  : 'defects',       
              fetch: 'FormattedID,Name,SubmittedBy,Iteration,Name,Project,Name,CreationDate,ScheduleState,State',
              query : '((State != "Closed") OR (ScheduleState != "Accepted"))',
            };
            rallyDataSource.findAll(config, showTable);
            rallyDataSource.setApiVersion("1.38");
        }

        rally.addOnLoad(onLoad);

    </script>

</head>
<body>
<div id="aDiv"></div>
<div style="font-weight: bold;"><p>Defects</p></div>
<div id="defectsDiv"></div>
</body>
</html>
于 2012-11-09T05:56:45.180 回答