我有一个简单的拉力赛应用程序,呈现基本网格。我通过寻找" WorkProduct.AcceptedDate"来过滤在两个日期之间,这很好。
我遇到的问题是我还要退回" WorkProduct.AcceptedDate"在数据网格中,但这似乎不想工作:(
那么您认为我没有考虑到什么?
<!DOCTYPE html>
<html>
<head>
<title>Grid Example</title>
<script type="text/javascript" src="/apps/2.0rc1/sdk.js"></script>
<script type="text/javascript">
Rally.onReady(function() {
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function() {
Rally.data.ModelFactory.getModel({
type: 'Task',
success: function(model) {
this.grid = this.add({
xtype: 'rallygrid',
model: model,
columnCfgs: [
'FormattedID',
'Name',
'Owner',
'Estimate',
'WorkProduct',
'WorkProduct.AcceptedDate',
'ToDo',
'c_HoursWorked'
],
storeConfig: {
filters: [
{
property: 'WorkProduct.AcceptedDate',
operator: '>=',
value: '2016-07-01T23:59:59.000Z'
},
{
property: 'WorkProduct.AcceptedDate',
operator: '<=',
value: '2016-07-31T23:59:59.000Z'
}
]
}
});
},
scope: this
});
}
});
Rally.launchApp('CustomApp', {
name: 'Grid Example'
});
});
</script>
<style type="text/css">
</style>
</head>
<body></body>
</html>
答案 0 :(得分:0)
你非常接近拥有它。看看下面的例子。
您只需在columnCfgs中指定AcceptedDate列,并包含一个渲染器函数即可正确渲染日期。
需要进行的第二项更改是将AcceptedDate添加到storeConfig中的fetch中,以便我们确保为每个关联的WorkProduct返回数据。
我还将您的应用升级到最新的SDK版本2.1。
<!DOCTYPE html>
<html>
<head>
<title>Grid Example</title>
<script type="text/javascript" src="/apps/2.1/sdk.js"></script>
<script type="text/javascript">
Rally.onReady(function() {
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function() {
Rally.data.ModelFactory.getModel({
type: 'Task',
success: function(model) {
this.grid = this.add({
xtype: 'rallygrid',
model: model,
columnCfgs: [
'FormattedID',
'Name',
'Owner',
'Estimate',
'WorkProduct',
//Use object syntax for specifying a column here, including a renderer function.
{
text: 'Accepted Date',
dataIndex: 'WorkProduct',
renderer: function(value, metaData, record) {
var date = record.get('WorkProduct').AcceptedDate;
return Rally.util.DateTime.formatDate(date);
}
},
'ToDo',
'c_HoursWorked'
],
storeConfig: {
filters: [
{
property: 'WorkProduct.AcceptedDate',
operator: '>=',
value: '2016-07-01T23:59:59.000Z'
},
{
property: 'WorkProduct.AcceptedDate',
operator: '<=',
value: '2016-07-31T23:59:59.000Z'
}
],
//need to fetch AcceptedDate as well
fetch: ['AcceptedDate']
}
});
},
scope: this
});
}
});
Rally.launchApp('CustomApp', {
name: 'Grid Example'
});
});
</script>
<style type="text/css">
</style>
</head>
<body></body>
</html>