2016-12-14 7 views
1

私はカスタムデータを表示し、Excelにデータをエクスポートすることができるラリーページを作成しようとしています。 rallygridにデータを表示することができます(カスタムフィールドを計算して表示することができます)。また、データをラリーグリッドボードに表示することもできますが、データをエクスポートすることはできますが、両方を行うことができるようです。Rally:TreeStoreBuilderとrallygridboardでカスタムデータを使用

誰でも私がこの仕事をするために何ができるかについてのアイデアはありますか?

表示するカスタムデータは、ユーザーストーリーのフィーチャーの親イニシアチブ名fwiwです。

Rally's examplesには、カスタムデータをグリッドに表示するコードがあります。私はスペースを節約するためにここに完全なコードを貼り付けないであろうが、ここではその一例からの関連抜粋です:

 launch: function() { 
       Ext.create('Rally.data.wsapi.Store', { 
        model: 'userstory', 
        autoLoad: true, 
        listeners: { 
         load: this._onDataLoaded, 
         scope: this 
        }, 
        fetch: ['FormattedID', 'Name', 'ScheduleState', 'Tasks', 'Defects'] 
       }); 
      }, 

      _onDataLoaded: function(store, data) { 
       var records = _.map(data, function(record) { 
        //Perform custom actions with the data here 
        //Calculations, etc. 
        return Ext.apply({ 
         TaskCount: record.get('Tasks').Count 
        }, record.getData()); 
       }); 

      this.add({ 
        xtype: 'rallygrid', 
        showPagingToolbar: false, 
        showRowActionsColumn: false, 
        editable: false, 
        store: Ext.create('Rally.data.custom.Store', { 
         data: records 
        }), 

....

これはrallygridとの素晴らしい作品が、rallygridはいないようですcsvへのエクスポートをサポートします。

rallygridをrallygridboardに切り替えると、同じアプローチ(_onDataLoadedを使用)は機能しません。 _onDataLoadedに次の行でエラーが表示されます。 var feature = record.get( 'Feature'); 私は次のエラーが発生します: "record.getは関数ではありません"

ここに私のフルコードです。これはTasks(これはRallyのサンプルファイル)ではなく、実際に必要なデータ(ユーザーストーリーのもの)を取得するためにコード化されています。

<!DOCTYPE html> 
<html> 
<head> 
<title>Exportable Grid Board Example</title> 

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

<script type="text/javascript"> 
    var recordCount = 0; 

    Rally.onReady(function() { 
     Ext.define('Rally.example.ExportableGridBoard', { 
      extend: 'Rally.app.App', 
      componentCls: 'app', 

      launch: function() { 
       Ext.create('Rally.data.wsapi.TreeStoreBuilder').build({ 
        models: ['portfolioitem/feature','userstory'], 
        autoLoad: true, 
        enableHierarchy: true, 
        listeners: { 
         load: this._onDataLoaded, 
         scope: this 
        } 
       }).then({ 
        success: this._onStoreBuilt, 
        scope: this 
       }); 
      }, 

      _onDataLoaded: function (store, data) { 
       var records = _.map(data, function (record) { 
        //Perform custom actions with the data here 
        //Calculations, etc. 

        //console.log(record); 
        recordCount++; 

        var feature = record.get('Feature'); 

        var featureName; 
        var initiative; 
        var initiativeName; 

        if (feature == null) { 
         featureName = ''; 
         initiative = ''; 
         initiativeName = ''; 
        } 
        else { 
         featureName = feature.FormattedID + ' ' + feature.Name; 
         initiative = feature.Parent; 

         if (initiative == null) { 
          initiativeName = ''; 
         } 
         else { 
          initiativeName = initiative.FormattedID + ' ' + initiative.Name; 
         } 

        } 

        return Ext.apply({ 
          featureName: featureName, 
          initiativeName: initiativeName 
         }, record.getData()); 
       }) 
      },//_onDataLoaded 


      _onStoreBuilt: function(store) { 

       //this._onDataLoaded(store, store.data); 

       //console.log('num records: '+ recordCount);//seems to always be 0 

       var modelNames = ['userstory'], 
        context = this.getContext(); 

       this.add({ 
        xtype: 'rallygridboard', 
        context: context, 
        modelNames: modelNames, 
        toggleState: 'grid', 
        stateful: false, 
        plugins: [ 
         { 
          ptype: 'rallygridboardactionsmenu', 
          menuItems: [ 
           { 
            text: 'Export...', 
            handler: function() { 
             window.location = Rally.ui.gridboard.Export.buildCsvExportUrl(
              this.down('rallygridboard').getGridOrBoard()); 
            }, 
            scope: this 
           } 
          ], 
          buttonConfig: { 
           iconCls: 'icon-export' 
          } 
         } 
        ], 
        gridConfig: { 
         store: store, 
         columnCfgs: [ 
          'Name', 
          'ScheduleState', 
          //'c_AffinityEstimate', 
          'PlanEstimate', 
          'Project', 
          'Feature', 
          'Feature.Parent', 
          'featureName', 
          'initiativeName' 
         ] 
        }, 
        height: this.getHeight() 
       }); 
      } 
     }); 


     Rally.launchApp('Rally.example.ExportableGridBoard', { 
      name: 'Exportable Grid Board Example' 
     }); 
    }); 
</script> 

<style type="text/css"> 

</style> 
</head> 
<body></body> 
</html> 
+0

は、上記の、私は次のように持っています。 Feature.Parentは機能せず、record.get()が機能していないため、計算している変数(featureNameとinitiativeName)は入力されません。 – sgeffner

答えて

0

データのエクスポートは、すべてのデータがWSAPIクエリから取り込まれたグリッドでのみサポートされます。カスタムデータをエクスポートするには、クライアントでCSV文字列を生成し、データURIを使用してダウンロードをトリガするコードを手動で記述する必要があります。

これを行うアプリの例を見つけようとしましたが、空になってしまいました。ここでのアプローチの説明は、しかしです:

https://developer.zendesk.com/blog/app-tricks-generate-csv-files-for-download-with-handlebars-and-data-uris

あなたよちょうどあなたの物語の各レコードをループし、その後、区切られた文字列を構築し、あなたはその結果にリンクすることができますまたはあなただけのwindow.locationのを設定することができますその結果に。デバッグのためにそこに冗長ですが、 '機能'、 'Feature.Parent'、 'FEATURENAME'、 'initiativeName' :私のコードで

+0

ありがとう!これは参考になります。 – sgeffner

関連する問題