我想创建一个拉力赛页面,显示自定义数据,并允许我将数据导出到Excel。我很挣扎,因为我可以在rallygrid中显示数据(它允许我计算自定义字段并显示它们),或者我可以在rallygridboard中显示数据(它允许我导出数据),但是我没有似乎能够做到这一点。拉力赛:与TreeStoreBuilder和rallygridboard使用自定义数据
任何人有什么想法,我可以做什么使这项工作?
我想要显示的自定义数据是用户故事的Feature的父级Initiative名称fwiw。
Rally's examples中的代码显示了如何在网格中显示自定义数据。我不会在这里贴全代码,以节省空间,但这里是从他们的例子相关片段:
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。
当我将rallygrid切换为rallygridboard时,相同的方法(使用_onDataLoaded)不起作用。我在这一行的_onDataLoaded中出现错误: var feature = record.get('Feature'); 我得到的错误是:“record.get不是一个函数”
这是我的完整代码。请注意,这是编码得到其实我想要的数据(这是用户故事的东西),而不是任务(这只是个例子拉力文件)。
<!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.Parent', 'featureName', 'initiativeName' 是多余的,但没有进行调试。 Feature.Parent不工作,和我计算的变量(featureName和initiativeName)没有得到填补,因为record.get()不工作。 – sgeffner