1

我正在尝试创建一个在网格视图中显示数据的自定义 Rally 应用程序。在另一个问题Rally SDK App Using Grid with collapsible tree of children stories 中nickm发布了一些示例代码

Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function() {
    var today = new Date().toISOString();
    Ext.create('Rally.data.wsapi.Store', {
            model: 'UserStory',
            fetch: ['ObjectID', 'FormattedID', 'Name', 'ScheduleState', 'Feature'],
            autoLoad: true,
            filters: [
                {
                    property: 'Iteration.StartDate',
                    operator: '<=',
                    value: today
                },
                {
                    property: 'Iteration.EndDate',
                    operator: '>=',
                    value: today
                },
                {
                    property: 'Feature',
                    operator: '!=',
                    value: null
                }
            ],
            listeners: {
                load: this._onDataLoaded,
                scope: this
            }
            });
},
_onDataLoaded: function(store, records){
    var that = this;
    var promises = [];
     _.each(records, function(story) {
        promises.push(that._getFeature(story, that));
    });

    Deft.Promise.all(promises).then({
        success: function(results) {
            that._stories = results;
            that._makeGrid();
        }
    });
},

_getFeature: function(story, scope) {
    var deferred = Ext.create('Deft.Deferred');
    var that = scope;
        var featureOid = story.get('Feature').ObjectID;
        Rally.data.ModelFactory.getModel({
        type: 'PortfolioItem/Feature',
        scope: this,
        success: function(model, operation) {
            fetch: ['State'],
            model.load(featureOid, {
                scope: this,
                success: function(record, operation) {
                    var featureState = record.get('State')._refObjectName;
                    var storyRef = story.get('_ref');
                    var storyOid  = story.get('ObjectID');
                    var storyFid = story.get('FormattedID');
                    var storyName  = story.get('Name');
                    var storyState = story.get('ScheduleState');
                    var feature = story.get('Feature');

                    result = {
                                "_ref"          : storyRef,
                                "ObjectID"      : storyOid,
                                "FormattedID"   : storyFid,
                                "Name"          : storyName,
                                "ScheduleState" : storyState,
                                "Feature"       : feature,
                                "FeatureState"  : featureState,
                                "FeatureID"     : featureOid   
                            };
                    deferred.resolve(result);    
                }
            });
        }
    });
    return deferred; 
},

_makeGrid: function() {
    var that = this;

    if (that._grid) {
        that._grid.destroy();
    }

    var gridStore = Ext.create('Rally.data.custom.Store', {
        data: that._stories,
        groupField: 'FeatureID',
        pageSize: 1000,
    });

    that._grid = Ext.create('Rally.ui.grid.Grid', {
        itemId: 'storyGrid',
        store: gridStore,
        features: [{ftype:'grouping'}],
        columnCfgs: [
            {
                text: 'Formatted ID', dataIndex: 'FormattedID', xtype: 'templatecolumn',
                tpl: Ext.create('Rally.ui.renderer.template.FormattedIDTemplate')
            },

            {
                text: 'Name', dataIndex: 'Name', 
            },
            {
                text: 'ScheduleState', dataIndex: 'ScheduleState', 
            },
            {
                text: 'Feature', dataIndex: 'Feature',
                renderer: function(val, meta, record) {
                    return '<a href="https://rally1.rallydev.com/#/detail/portfolioitem/feature/' + record.get('Feature').ObjectID + '" target="_blank">' + record.get('Feature').FormattedID + '</a>';
                }
            },
            {
                text: 'Feature State', dataIndex: 'FeatureState',
            }
        ]
    });

    that.add(that._grid);
    that._grid.reconfigure(gridStore);
}
});

我想以与 Rally Grid 显示它们的方式相同的方式显示 ScheduleState 和 Blocked 列(作为图形表示)。我试图通过在我的 columnCfgs 块中使用以下内容来弄清楚如何使用 templatecolumn xtype:

{   text: 'State', dataIndex: 'ScheduleState', xtype: 'templatecolumn',
                tpl: Ext.create('Rally.ui.renderer.template.ScheduleStateTemplate') }

这会失败并导致 sdk-debug.js 中出现 JS 错误:

未捕获的类型错误:无法读取未定义 sdk-debug.js:190539 Ext.define.loadStates 的属性“getAllowedValueStore”

我在 Blocked 列中遇到了不同的错误,但我无法弄清楚如何让它显示为红色的阻止图标。

这就是我想要实现的目标

4

1 回答 1

0

通过一些调整,我希望这可以在 AppSDK2 的下一个版本中使用,但现在 ScheduleState 和 Blocked 的呈现仅适用于 wsapi 数据存储。使用

tpl: Ext.create('Rally.ui.renderer.template.ScheduleStateTemplate')

还不够。自定义商店无权访问有效状态。

更新

x截至本次更新之日,AppSDK2的当前版本中的 ScheduleState 和 Blocked 的渲染工作, 5/22

<script type="text/javascript" src="/apps/x/sdk.js"></script>

此修复程序最终将用于 AppSDK2 的下一个正式版本,但现在您可以将它与xAppSDK2 版本一起使用。

警告xAppSDK 版本永远不稳定 - 不断对其进行更改。

在此处查看完整的代码示例

xAppSDK 版本中,您可以这样做:

{
   text: 'ScheduleState', dataIndex: 'ScheduleState', xtype: 'templatecolumn',
      tpl: Ext.create('Rally.ui.renderer.template.ScheduleStateTemplate',
           {
              states: ['Defined', 'In-Progress', 'Completed', 'Accepted'],
              field: {name: 'ScheduleState' }
            })
},
{
   text: 'Blocked', dataIndex: 'Blocked', xtype: 'templatecolumn',
      tpl: Ext.create('Rally.ui.renderer.template.BlockedTemplate')
}

另外,现在,在网格配置中将其设置为 false:

enableBlockedReasonPopover: false
于 2014-05-19T14:05:18.860 回答