【发布时间】:2016-12-14 01:10:45
【问题描述】:
我正在尝试创建一个显示自定义数据并允许我将数据导出到 Excel 的 Rally 页面。我正在苦苦挣扎,因为我可以在 rallygrid 中显示数据(这允许我计算自定义字段并显示它们),或者我可以在 rallygridboard 中显示数据(它允许我导出数据),但我没有似乎两者都可以。
有人对我可以做些什么来完成这项工作有任何想法吗?
我要显示的自定义数据是用户故事的功能的父倡议名称,fwiw。
Rally's examples 中的代码显示了如何在网格中显示自定义数据。我不会在此处粘贴完整代码以节省空间,但这里有一个来自他们示例的相关 sn-p:
launch: function() {
Ext.create('Rally.data.wsapi.Store', {
model: 'userstory',
autoLoad: true,
listeners: {
load: this._onDataLoaded,
scope: this
},
fetch: ['FormattedID', 'Name', 'ScheduleState', 'Tasks', 'Defects']
});
},
_onDataLoaded: function(store, data) {
var records = _.map(data, function(record) {
//Perform custom actions with the data here
//Calculations, etc.
return Ext.apply({
TaskCount: record.get('Tasks').Count
}, record.getData());
});
this.add({
xtype: 'rallygrid',
showPagingToolbar: false,
showRowActionsColumn: false,
editable: false,
store: Ext.create('Rally.data.custom.Store', {
data: records
}),
....
这适用于 rallygrid,但 rallygrid 似乎不支持导出到 csv。
当我将拉力网格切换为拉力网格板时,同样的方法(使用 _onDataLoaded)不起作用。我在这一行的 _onDataLoaded 中收到错误: var feature = record.get('Feature'); 我得到的错误是:“record.get 不是函数”
这是我的完整代码。请注意,这是为了获取我真正想要的数据(这是用户故事的东西),而不是任务(这只是 Rally 示例文件)。
<!DOCTYPE html>
<html>
<head>
<title>Exportable Grid Board Example</title>
<script type="text/javascript" src="/apps/2.1/sdk.js"></script>
<script type="text/javascript">
var recordCount = 0;
Rally.onReady(function() {
Ext.define('Rally.example.ExportableGridBoard', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function() {
Ext.create('Rally.data.wsapi.TreeStoreBuilder').build({
models: ['portfolioitem/feature','userstory'],
autoLoad: true,
enableHierarchy: true,
listeners: {
load: this._onDataLoaded,
scope: this
}
}).then({
success: this._onStoreBuilt,
scope: this
});
},
_onDataLoaded: function (store, data) {
var records = _.map(data, function (record) {
//Perform custom actions with the data here
//Calculations, etc.
//console.log(record);
recordCount++;
var feature = record.get('Feature');
var featureName;
var initiative;
var initiativeName;
if (feature == null) {
featureName = '';
initiative = '';
initiativeName = '';
}
else {
featureName = feature.FormattedID + ' ' + feature.Name;
initiative = feature.Parent;
if (initiative == null) {
initiativeName = '';
}
else {
initiativeName = initiative.FormattedID + ' ' + initiative.Name;
}
}
return Ext.apply({
featureName: featureName,
initiativeName: initiativeName
}, record.getData());
})
},//_onDataLoaded
_onStoreBuilt: function(store) {
//this._onDataLoaded(store, store.data);
//console.log('num records: '+ recordCount);//seems to always be 0
var modelNames = ['userstory'],
context = this.getContext();
this.add({
xtype: 'rallygridboard',
context: context,
modelNames: modelNames,
toggleState: 'grid',
stateful: false,
plugins: [
{
ptype: 'rallygridboardactionsmenu',
menuItems: [
{
text: 'Export...',
handler: function() {
window.location = Rally.ui.gridboard.Export.buildCsvExportUrl(
this.down('rallygridboard').getGridOrBoard());
},
scope: this
}
],
buttonConfig: {
iconCls: 'icon-export'
}
}
],
gridConfig: {
store: store,
columnCfgs: [
'Name',
'ScheduleState',
//'c_AffinityEstimate',
'PlanEstimate',
'Project',
'Feature',
'Feature.Parent',
'featureName',
'initiativeName'
]
},
height: this.getHeight()
});
}
});
Rally.launchApp('Rally.example.ExportableGridBoard', {
name: 'Exportable Grid Board Example'
});
});
</script>
<style type="text/css">
</style>
</head>
<body></body>
</html>
【问题讨论】:
-
在我上面的代码中,我有以下内容:'Feature'、'Feature.Parent'、'featureName'、'initiativeName' 这是多余的,但用于调试。 Feature.Parent 不起作用,并且我正在计算的变量(featureName 和 InitiativeName)没有被填写,因为 record.get() 不起作用。
-
您找到解决方案了吗?在网格板中显示自定义数据。请告诉我。
标签: rally