2

私は Rally 開発に非常に慣れていないので、私の質問はばかげているように聞こえるかもしれません (しかし、rally のヘルプまたはここの以前の投稿からそれを行う方法を見つけることができませんでした) :)

ラリー フリーフォーム グリッドの例から始めました。私の目的はビジネス価値計算機を実装することです。スコア フィールドに 5 桁の数値を入力します。各数字は 1 ~ 5 の範囲のスコアです。次に、計算の結果としてビジネス価値を計算します。ここで、各数値は事前設定された重みで重み付けされます。ストーリーをビジネス価値別に並べ替えて、バックログに優先順位を付けることができます。これが最初のステップであり、うまくいきます。

ここでやりたいことは、フリーフォーム グリッドを編集可能にすることです。各桁を個別の列として抽出していますが、それらの列は表示専用です。それらを編集可能なものにするにはどうすればよいですか? もちろんやりたいことは、各カスタム列に入力された値に基づいてスコア フィールドを更新することです。

例を次に示します。スコアが「15254」のレコードがあります。これは、ビジネス価値基準 1 が 5 点満点中 1 点を獲得し、ビジネス価値基準 2 が 5 点満点中 5 点を獲得することを意味します。最終的に、私のビジネス価値が計算されます。 「1*​​1 + 5*2 + 2*3 + 5*4 + 4*5 = 57」として。これまでのところ、これは機能する部分です。ここで、3 番目の基準のスコアが 2 ではなく 3 であることを発見したとします。対応する列の値を編集して、スコア フィールドを「15354」に更新し、ビジネス価値を 57 ではなく 60 と表示できるようにしたいとします。 .

これが私の現在のコードです。そのグリッドを編集可能なものに変えるのを手伝ってくれれば本当に感謝しています:)

<!--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>

4

1 に答える 1

1

Kyle がコメントで述べたように、最善の策は、インメモリ ストアを使用する代わりに、ユーザー ストーリー モデルを拡張することです。

それを拡張するには、Rally.data.ModelFactory を使用してモデルを取得し、次のようにします。

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

次に、Score フィールドのconvert構成を使用して、計算フィールドの値を設定します。編集で設定されたスコアを取得するには、計算フィールドごとに変換構成も必要になる場合があります。

次に、ストアの代わりにカスタム モデルを使用するようにグリッドに指示します。

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'
        }
    ]
});
于 2012-09-17T15:36:52.147 に答える