1

我正在尝试使用以下代码将标签名称作为列获取:

查询对象:

var queryObject = {
                key: 'storiesBackLog',
                type: 'hierarchicalrequirement',
                fetch: 'FormattedID,Name,PlanEstimate,ScheduleState,Tags',
                query: '(ScheduleState = "Backlog")',
                order: 'FormattedID'
        };

表配置:

var config = { columns: 
           [    
                {key:'FormattedID', header:'ID', width:60},
                {key:'PlanEstimate', header:'Points', width:60},
                {key:'Name', header:'Name', width:400},
                {key:'Tags.Name', header:'Department', width:400},
           ] 
        };

使用 Tags.Name,结果为 ...,使用 Tags,结果为 [object Object]。有谁知道关键是什么?

最终解决方案:

rally.forEach(results.storiesBackLog, function(story) {
        var tags = [];
        rally.forEach(story.Tags, function(tag) {
            tags.push(tag.Name); 
        });
        story.TagNames = tags.join(';');
    });

    var tableBackLogConfig = { columns:
        [
            {key:'TagNames', header:'Department', width:400},
        ]
    }; 
4

1 回答 1

1

我认为 table 组件足够聪明,可以遍历对象图,但我敢打赌,Tags 是一个集合这一事实会绊倒它。您可能需要先自己处理数据并将名为 TagNames 的列添加到表中,而不是在从 RallyDataSource 返回数据时自行计算。

function onDataRetrieved(results) {
    rally.forEach(results.storiesBacklog, function(story) {
        story.TagNames = (story.Tags || []).join(', ');
    });

    var config = { columns:
        [ //...
            {key: 'TagNames', header 'Department', width: 400}
        ]
    };
    //create table 
}
于 2013-03-08T14:50:28.540 回答