0

我想创建一个应用程序,列出用户故事及其前身以及他们创建(添加)到 Rally 的日期。

有什么我可以使用的例子吗?

4

1 回答 1

0

这里有一个简单的例子来说明如何做到这一点。您可以通过创建一个格式化函数来将 Predecessor FormattedID 呈现为链接来使它变得更有趣,但这应该给您基本的想法:

    <!DOCTYPE html>
    <html>
    <head>
        <title>UserStoryWithPredecessors</title>

        <script type="text/javascript" src="https://rally1.rallydev.com/apps/2.0p5/sdk.js"></script>

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

                    launch: function() {
                        Ext.create('Rally.data.WsapiDataStore', {
                            model: 'UserStory',
                            fetch: ['FormattedID','Name','Predecessors','FormattedID','CreationDate'],
                            autoLoad: true,
                            listeners: {
                                load: this._onDataLoaded,
                                scope: this
                            }
                        });
                    },                

                    _onDataLoaded: function(store, data) {
                        var records = [];
                        Ext.Array.each(data, function(record) {
                            //Perform custom actions with the data here
                            //Calculations, etc.

                            var myPredecessors = record.get('Predecessors');

                            var predecessorData = "";
                            var predecessorCreationDate = "";

                            // Loop through and process Predecessor data
                            for (var i=0; i<myPredecessors.length; i++) {
                                thisPredecessor = myPredecessors[i];
                                thisPredecessorFormattedID = thisPredecessor["FormattedID"];
                                thisPredecessorName = thisPredecessor["Name"];

                                // Re-format Date/time string
                                thisPredecessorCreationDateString = thisPredecessor["CreationDate"];
                                thisPredecessorCreationDate = new Date(thisPredecessorCreationDateString);
                                thisYear = thisPredecessorCreationDate.getFullYear();
                                thisMonth = thisPredecessorCreationDate.getMonth();
                                thisDay = thisPredecessorCreationDate.getDate();

                                thisPredecessorFormattedDate = thisMonth + "/" + thisDay + "/" + thisYear;

                                // Post-pend updated data to value for array
                                predecessorData += thisPredecessorFormattedID + ": " + thisPredecessorName + "<br>"                            
                                predecessorCreationDate += thisPredecessorFormattedDate + "<br>";                                    
                            }

                            records.push({
                                FormattedID: record.get('FormattedID'),
                                Name: record.get('Name'),
                                Predecessors: predecessorData,
                                PredecessorCreationDate: predecessorCreationDate
                            });
                        });

                        this.add({
                            xtype: 'rallygrid',
                            store: Ext.create('Rally.data.custom.Store', {
                                data: records,
                                pageSize: 20
                            }),
                            columnCfgs: [
                                {
                                    text: 'FormattedID', dataIndex: 'FormattedID', width: '60px'
                                },
                                {
                                    text: 'Name', dataIndex: 'Name', width: '400px'
                                },
                                {
                                    text: 'Predecessors', dataIndex: 'Predecessors', width: '200px'
                                },
                                {
                                    text: 'Predecessor Creation Date(s)', dataIndex: 'PredecessorCreationDate', width: '200px'
                                }
                            ]
                        });
                    }
                });
                Rally.launchApp('CustomApp', {
                    name: 'UserStoryWithPredecessors'
                });
            });
        </script>

        <style type="text/css">
            .app {
                 /* Add app styles here */
            }
        </style>
    </head>
    <body></body>
    </html>
于 2013-03-04T00:11:33.257 回答