首页 > 解决方案 > UserStory ScheduleState 在 Grid 中显示

问题描述

我正在尝试在网格中显示 UserStories 的 ScheduleState。我无法将 ScheduleState 显示为可编辑栏,就像我们在 Rally 中看到的那样,每个状态都有 DPCA 栏列。

例如,下面链接上的 SimpleTreeGrid 示例将用户故事计划状态显示为 DPCA 条形列。 https://help.rallydev.com/apps/2.1/doc/#!/example/simple-tree-grid

代码如下。

    <!DOCTYPE html>
    <html>
    <head>
    <title>Custom Store Grid Example</title>

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

    <script type="text/javascript">
        Rally.onReady(function() {
            Ext.define('Rally.example.CustomStoreGrid', {
                extend: 'Rally.app.App',
                componentCls: 'app',

                launch: function() {
                console.log('launch');
                    Ext.create('Rally.data.wsapi.Store', {
                        model: 'userstory',
                        autoLoad: true,
                        listeners: {
                            load: this._onDataLoaded,
                            scope: this
                        },
                        fetch: ['FormattedID', 'ScheduleState', 'ScheduleStatePrefix' ]
                    });
                },

                _onDataLoaded: function(store, data) {
                    console.log('_onDataLoaded data', data);
                    this.add({
                        xtype: 'rallygrid',
                        showPagingToolbar: false,
                        showRowActionsColumn: false,
                        editable: false,
                        store: Ext.create('Rally.data.custom.Store', {
                            data: data
                        }),
                        columnCfgs: [
                            {
                                xtype: 'templatecolumn',
                                text: 'ID',
                                dataIndex: 'FormattedID',
                                width: 100,
                                tpl: Ext.create('Rally.ui.renderer.template.FormattedIDTemplate')
                            },
                            {
                                text: 'Prefix',
                                dataIndex: 'ScheduleStatePrefix',
                                xtype: 'templatecolumn',
                                tpl: Ext.create('Rally.ui.renderer.template.ScheduleStateTemplate', { field: 'ScheduleStatePrefix'}),
                            },
                            {
                                text: 'State',
                                dataIndex: 'ScheduleState',
                                xtype: 'templatecolumn',
                                tpl: Ext.create('Rally.ui.renderer.template.ScheduleStateTemplate', { field: 'ScheduleState'}),
                            }
                        ]
                    });
                }
            });


            Rally.launchApp('Rally.example.CustomStoreGrid', {
              name: 'Custom Store Grid Example'
            });
        });
    </script>

    <style type="text/css">

    </style>
</head>
<body></body>
</html>

标签: sdkrallycode-rally

解决方案


它需要是一个自定义商店吗?

如果没有,以下 _onDataLoaded 有效:

            _onDataLoaded: function(store, data) {
                console.log('_onDataLoaded data', data);
                this.add({
                    xtype: 'rallygrid',
                    showPagingToolbar: false,
                    showRowActionsColumn: false,
                    editable: true,
                    store: store,
                    columnCfgs: [
                        {
                            text: 'ID',
                            dataIndex: 'FormattedID',
                            width: 100
                        },
                        {
                            text: 'Prefix',
                            dataIndex: 'ScheduleStatePrefix'
                        },
                        {
                            text: 'State',
                            dataIndex: 'ScheduleState'
                        }
                    ]
                });
            }
        });

推荐阅读