将PercentDoneByStoryPoint添加到HTML DIV

时间:2015-05-28 23:03:31

标签: rally confluence

在Rally SDK的1.x版本中,我能够使用如下查询查询并分配给HTML DIV:

var querySI48 = { 
  type : 'portfolioitem',
  query:'(Name = "Q3 2015 Release (2.8.0)")',
  key : 'SI48Key',
  fetch: 'PercentDoneByStoryCount'
};

并将其分配给这样的DIV:

var WS215 = document.getElementById("WS215");
WS215.innerHTML = "<h2>" + pisInfo + "%</h2>";

如何使用2.X SDK将PercentDoneByStoryPoint分配给DIV?我在Confluence中创建了一个包含Rally数据的仪表板。

1 个答案:

答案 0 :(得分:0)

类似于以下内容应该可以解决问题:

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

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

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

                launch: function() {

                    var me = this;

                    var divTemplateString = "<h2>{0}: Percent Done by Story Count = {1}</h2>";

                    Ext.create('Rally.data.wsapi.Store', {
                        model: 'PortfolioItem/Feature',
                        fetch: true,
                        autoLoad: true,
                        filters: [
                            {
                                property: 'FormattedID',
                                value: 'F15'
                            }
                        ],
                        listeners: {
                            load: function(store, data, success) {
                                var formattedID = data[0].get('FormattedID');
                                var pctDoneByStoryCount = data[0].get('PercentDoneByStoryCount');
                                var divHTML = Ext.String.format(divTemplateString, formattedID, pctDoneByStoryCount);
                                var div = Ext.get('F15');
                                me.add({
                                    xtype: 'container',
                                    html: divHTML,
                                    renderTo: div
                                });             
                            }
                        },                      
                    });
                }
            });


            Rally.launchApp('Rally.example.App', {
              name: 'Example'
            });
        });
    </script>

    <style type="text/css">

    </style>
</head>
<body>
<div id="F15"</div>
</body>
</html>