如何使用 AppSDK 2 构建网格,其中列是分辨率的下拉值? [英] How to build a grid with AppSDK 2 where columns are dropdown values of resolution?

查看:36
本文介绍了如何使用 AppSDK 2 构建网格,其中列是分辨率的下拉值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示通过迭代过滤的已关闭缺陷的摘要,每个分辨率的缺陷总数与此类似:

I want to show a summary of closed defects filtered by iteration with the total count of defects per resolution that looks similar to this:

推荐答案

以下是执行此操作的网格示例.在

Here is an example of a grid that does that. Replace '111' in

workspace: '/workspace/1111'

使用您工作区的 ObjectID.这篇文章展示了如何找到工作区的 OID.

with ObjectID of your workspace. This post shows how to find OID of workspace.

<!DOCTYPE html>
<html>
<head>
<title>closed defects by iteration</title>
<script type="text/javascript" src="/apps/2.0rc1/sdk.js"></script>
<script type="text/javascript">
    Rally.onReady(function () {
    Ext.define('CustomApp', {
        extend: 'Rally.app.TimeboxScopedApp',
        componentCls: 'app',
        scopeType: 'iteration',
        comboboxConfig: {
        fieldLabel: 'Select an Iteration:',
        labelWidth: 100,
        width: 300
        },

        addContent: function() {
        this._arr = [];
        var that = this;
        console.log('_addContent');

        Rally.data.ModelFactory.getModel({
            type: 'Defect',
            context: {
            workspace: '/workspace/1111'
            },
            success: function(model) {
            that._allowedValuesStore = model.getField( 'Resolution' ).getAllowedValueStore( );
            console.log("allowed values count", that._allowedValuesStore.getCount());
            that._getDropdownValues();
            that._makeStore();
            }
        });
        },

        _getDropdownValues: function(){
        var that = this;
        this._allowedValuesStore.load({
        scope: this,
        callback: function(records, operation, success){
            console.log(records[1].get('StringValue'));
            Ext.Array.each(records, function(val) {
                    var s = val.get('StringValue');
                    that._arr.push(s);
            });
            console.log("arr[2]", this._arr[2])
            }
        });
        },

        _makeStore: function(){

         console.log('_makeStore');
         var filter = Ext.create('Rally.data.QueryFilter', {
                    property: 'Priority',
                    operator: '=',
                    value: 'Resolve Immediately'
                    });
                    filter = filter.or({
                    property: 'Priority',
                    operator: '=',
                    value: 'High Attention'  
                    });

                    filter = filter.and({
                    property: 'State',
                    operator: '=',
                    value: 'Closed'  
                    });


                    filter = filter.and(this.getContext().getTimeboxScope().getQueryFilter());

                    filter.toString();



         Ext.create('Rally.data.WsapiDataStore', {
            model: 'Defect',
            fetch: ['FormattedID','Name','Tasks','State','Resolution','Priority'],
            pageSize: 100,
            autoLoad: true,
            filters: [filter],
            listeners: {
            load: this._onDataLoaded,
            scope: this
            }
        }); 
        },

       onScopeChange: function() {
        console.log('onScopeChange');
        this._makeStore();
        },

        _onDataLoaded: function(store, data){
            console.log('_onDataLoaded');
            var defects = [];
            if (data.length === 0) {
                this._createGrid(defects);  
            }

            var countArchitecture=0;
            var countCodeChange=0;
            var countNotADefect=0;
            var countNone = 0;
            var countConfigurationChange =0;
            var countDatabaseChange = 0;
            var countDuplicate = 0;
            var countNeedMoreInformation =0;
            var countSoftwareLimitation =0;
            var countUserInterface = 0;


            Ext.Array.each(data, function(defect) {

                    var resolution = defect.get('Resolution');
                    switch(resolution)
                    {
                    case "Architecture":
                      countArchitecture++;
                      break;
                    case "Code Change":
                      countCodeChange++;
                      break;
                    case "Not a Defect":
                      countNotADefect++;
                      break;
                    case "None":
                      countNone++;
                      break;
                    case "Configuration Change":
                      countConfigurationChange++;
                      break;
                    case "Database Change":
                      countDatabaseChange++;
                      break;
                    case "Duplicate":
                      countDuplicate++;
                      break;
                    case "Need More Information":
                      countDuplicate++;
                      break;
                    case "Software Limitation":
                      countSoftwareLimitation++;
                      break;
                    case "User Interface":
                      countUserInterface++;
                      break;
                    default:
                      countNone++;
                    }
            });

                    var d  = {
                    'Architecture': countArchitecture,
                    'Code Change': countCodeChange,
                    'Not a Defect' : countNotADefect,
                    '' : countNone, 
                    'Configuration Change': countConfigurationChange,
                    'Database Change': countDatabaseChange,
                    'Duplicate': countDuplicate,
                    'Need More Information': countNeedMoreInformation,
                    'Software Limitation': countSoftwareLimitation,
                    'User Interface':countUserInterface,
                    };

                   defects.push(d);
                   this._createGrid(defects);         
        },

        _createGrid: function(defects) {
        console.log('_createGrid');
        console.log('this._arr[3]', this._arr[3]);
        var that = this;

        var myStore = Ext.create('Rally.data.custom.Store', {
            data: defects,
            pageSize: 100,  
            });

        var columnConfig = [];

            for (var i=0;i<this._arr.length; i++) {
                var columnConfigElement = {}; 
                columnConfigElement['text'] = that._arr[i];
                columnConfigElement['dataIndex'] = that._arr[i];
                columnConfig.push(columnConfigElement);
            }

        console.log('columnConfig', columnConfig);

        if (!this.grid) {
        this.grid = this.add({
            xtype: 'rallygrid',
            itemId: 'mygrid',
            store: myStore,
            columnCfgs: columnConfig
        });

         }else{
            this.grid.reconfigure(myStore);
         }
        }

});


            Rally.launchApp('CustomApp', {
                name:"closed defects by iteration",
                //parentRepos:""
            });

        });
    </script>
    <style type="text/css">
.app {
    margin: 10px;
}

.header {
    margin: 5px;
}

    </style>

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

这是它的样子:

这篇关于如何使用 AppSDK 2 构建网格,其中列是分辨率的下拉值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆