本文介绍了从 Rally 获取特定标签以计算另一个字段中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Rally 开发非常陌生,所以我的问题可能听起来很愚蠢(但无法从 Rally 的帮助或以前的帖子中找到如何解决):)

I'm extremely new to Rally development so my question may sound dumb (but couldn't find how to do it from rally's help or from previous posts here) :)

我从拉力赛自由形式网格示例开始 - 我的目的是实现一个商业价值计算器:我用 5 位数字填充分数字段,其中每个数字都是 1-5 范围内的分数.然后我计算作为计算结果的业务价值,其中每个数字都按预设权重加权.我可以按业务价值对我的故事进行排序,以帮助我确定待办事项的优先级:这是第一步,而且很有效.

I've started from the rally freeform grid example - my purpose is to implement a Business Value calculator: I fill the score field with a 5-digit figure where each number is a score in the 1-5 range.Then I compute a business value as the result of a calculation, where each number is weighted by a preset weight.I can sort my stories by Business Value to help me prioritize my backlog: that's the first step, and it works.

现在我想做的是使我的自由格式网格可我将每个数字提取为一个单独的列,但这些列仅用于显示.我怎样才能把它们变成可编辑的东西?我当然想做的是根据每个自定义列中输入的值更新分数字段.

Now what I want to do is to make my freeform grid editable: I am extracting each of my digits as a separate column, but those columns are display-only. How can I turn them into something editable? What I want to do of course is update back the score field based on the values input in each custom column.

这是一个例子:我有一个得分为15254"的记录,这意味着商业价值标准 1 得分 1 分(满分 5 分),商业价值标准 2 得分 5 分(满分 5 分),依此类推...最后,我的商业价值计算为1*1 + 5*2 + 2*3 + 5*4 + 4*5 = 57".到目前为止,这是有效的部分.现在假设我发现第三个标准不应该得分 2 而是 3,我希望能够编辑相应列中的值并将我的得分字段更新为15354",并且我的业务价值显示 60 而不是 57.

Here's an example:I have a record with score "15254", which means Business Value criteria 1 scores 1 out of 5, Business Value criteria 2 scores 5 out of 5, and so on...In the end my Business Value is computed as "1*1 + 5*2 + 2*3 + 5*4 + 4*5 = 57".So far this is the part that works.Now let's say I found that the third criteria should not score 2 but 3, I want to be able to edit the value in the corresponding column and have my score field updated to "15354", and my Business Value to display 60 instead of 57.

这是我当前的代码,如果您能帮助我将该网格变成可编辑的内容,我将不胜感激:)

Here is my current code, I'll be really grateful if you can help me with turning that grid into something editable :)

<!--Include SDK-->
<script type="text/javascript" src="https://rally1.rallydev.com/apps/2.0p2/sdk-debug.js"></script>

<!--App code-->
<script type="text/javascript">

    Rally.onReady(function() {

        Ext.define('BVApp', {
            extend: 'Rally.app.App',
            componentCls: 'app',

            launch: function() {
            Ext.create('Rally.data.WsapiDataStore', {
                    model: 'UserStory',
                    autoLoad: true,
                    listeners: {
                        load: this._onDataLoaded,
                        scope: this
                    }
                });
            },

            _onDataLoaded: function(store, data) {
                var records = [];
                var li_score;
                var li_bv1, li_bv2, li_bv3, li_bv4, li_bv5, li_bvtotal;
                var weights = new Array(1, 2, 3, 4, 5);

                Ext.Array.each(data, function(record) {
                    //Let's fetch score and compute the business values...
                    li_score = record.get('Score');
                    if (li_score) {
                        li_bv1 = li_score.toString().substring(0,1);
                        li_bv2 = li_score.toString().substring(1,2);
                        li_bv3 = li_score.toString().substring(2,3);
                        li_bv4 = li_score.toString().substring(3,4);
                        li_bv5 = li_score.toString().substring(4,5);
                        li_bvtotal =
                            li_bv1*weights[0] +
                            li_bv2*weights[1] +
                            li_bv3*weights[2] +
                            li_bv4*weights[3] +
                            li_bv5*weights[4];
                    }
                    records.push({
                        FormattedID: record.get('FormattedID'),
                        ref: record.get('_ref'),
                        Name: record.get('Name'),
                        Score: record.get('Score'),
                        Bv1: li_bv1,
                        Bv2: li_bv2,
                        Bv3: li_bv3,
                        Bv4: li_bv4,
                        Bv5: li_bv5,
                        BvTotal: li_bvtotal
                    });
                });

                this.add({
                    xtype: 'rallygrid',
                    store: Ext.create('Rally.data.custom.Store', {
                        data: records,
                        pageSize: 5
                    }),
                    columnCfgs: [
                        {
                            text: 'FormattedID', dataIndex: 'FormattedID'
                        },
                        {
                            text: 'ref', dataIndex: 'ref'
                        },
                        {
                            text: 'Name', dataIndex: 'Name', flex: 1
                        },
                        {
                            text: 'Score', dataIndex: 'Score'
                        },
                        {
                            text: 'BusVal 1', dataIndex: 'Bv1'
                        },
                        {
                            text: 'BusVal 2', dataIndex: 'Bv2'
                        },
                        {
                            text: 'BusVal 3', dataIndex: 'Bv3'
                        },
                        {
                            text: 'BusVal 4', dataIndex: 'Bv4'
                        },
                        {
                            text: 'BusVal 5', dataIndex: 'Bv5'
                        },
                        {
                            text: 'BusVal Total', dataIndex: 'BvTotal'
                        }
                    ]
                });
            }
        });

        Rally.launchApp('BVApp', {
            name: 'Business Values App'
        });

                var exampleHtml = '<div id="example-intro"><h1>Business Values App</h1>' +
                '<div>Own sample app for Business Values</div>' +
                                '</div>';

                // Default app viewport uses layout: 'fit',
                // so we need to insert a container into the viewport
                var viewport = Ext.ComponentQuery.query('viewport')[0];
                var appComponent = viewport.items.getAt(0);
                var viewportContainerItems = [{
                    html: exampleHtml,
                    border: 0
                }];

                //hide advanced cardboard live previews in examples for now

                    viewportContainerItems.push({
                        xtype: 'container',
                        items: [appComponent]
                    });


                viewport.remove(appComponent, false);
                viewport.add({
                    xtype: 'container',
                    layout: 'vbox',
                    items: viewportContainerItems
                });
    });


</script>

<!--App styles-->
<style type="text/css">
    .app {
        /* Add app styles here */
    }
</style>

推荐答案

就像 Kyle 在他的评论中所说的那样,最好的办法是扩展用户故事模型,而不是使用内存存储.

Like Kyle said in his comment, your best bet is to extend the user story model instead of using an in-memory store.

要扩展它,您可以使用 Rally.data.ModelFactory 来获取模型,然后执行以下操作:

To extend it, you can use the Rally.data.ModelFactory to get the model and then do something like this:

Rally.data.ModelFactory.getModel({
    type: 'user story',
    success: function(model){
        this.CustomModel = Ext.define('BVModel', {
            extend: model,
            fields: [
                {name: 'Bv1'}
                ...
            ]
        });
    },
    scope: this
});

然后使用转换 Score 字段上的配置以设置计算字段的值.要在编辑中设置分数,您可能还需要在每个计算字段上进行转换配置.

And then use the convert config on the Score field to set the values of your calculated fields. To get the Score set on an edit you might also need a convert config on each calculated field too.

然后告诉网格使用您的自定义模型而不是商店:

And then tell the grid to use your custom model instead of a store:

this.add({
    xtype: 'rallygrid',
    model: this.CustomModel,
    columnCfgs: [
        {
            text: 'FormattedID', dataIndex: 'FormattedID'
        },
        {
            text: 'ref', dataIndex: 'ref'
        },
        {
            text: 'Name', dataIndex: 'Name', flex: 1
        },
        {
            text: 'Score', dataIndex: 'Score'
        },
        {
            text: 'BusVal 1', dataIndex: 'Bv1'
        },
        {
            text: 'BusVal 2', dataIndex: 'Bv2'
        }
    ]
});

这篇关于从 Rally 获取特定标签以计算另一个字段中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 07:40