具有依赖关系的用户故事基于迭代

时间:2014-08-28 12:46:58

标签: javascript rally appsdk2

我是Rally以及javascript的新手。我从这个网站上获取了脚本,我想要包含迭代名称和记录。但是当我执行HTML页面时,它给了我对象对象消息。我需要解决这个问题。寻求帮助,并提前感谢。

-Mani

description here][1]

 <!DOCTYPE html>
 <html>
 *emphasized text*<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','Iteration','Predecessors','FormattedID','CreationDate'],
                        autoLoad: true,



                        listeners: {
                            load: this._onDataLoaded,
                                                           ///query: q,
                            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'),
                            Iteration: String(record.get('Iteration')), 
                            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: 'Iteration', dataIndex: 'Iteration', width: '500px'
                            },
                            {
                                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> 

1 个答案:

答案 0 :(得分:0)

用户素材对象上的迭代属性是对WS API中实际Iteration对象的引用。您需要使用如下语法遍历名称:

Iteration:  (record.get('Iteration') && record.get('Iteration')._refObjectName) || 'None'

您希望在输出record.get('Iteration')._refObjectName)

之前检查迭代是否为空