2012-04-30 13 views
2

私は、ユーザーのストーリーが持つかもしれない添付ファイルへのリンクを引き出す方法を見つけようとしていますが、どうやってその方法を理解することはできませんでした。私が持っているように、私のコラムで唯一得られるのは、ユーザーストーリーに添付ファイルがあるときに "[オブジェクトオブジェクト]"です。添付ファイルへのリンク

添付ファイルをつかんでいるところが多いようですが、誰かが光を放つか正しい方向に向けることができれば、私は確かにそれを感謝します!

<html> 
<head> 
    <title>Table</title> 
    <meta name="Name" content="App Example: Table" /> 
    <meta name="Version" content="2010.4" /> 
    <meta name="Vendor" content="Rally Software" /> 
    <script type="text/javascript" src="https://rally1.rallydev.com/apps/1.24/sdk.js?loginKey=bignumber"></script> 
    <script type="text/javascript"> 

    function tableExample() { 
     var rallyDataSource = new rally.sdk.data.RallyDataSource('12345', '12345',  'True', 'True'); 
     function itemQuery() { 
     var queryObject = { 
      key: 'stories', 
      type: 'HierarchicalRequirement', 
      fetch: 'FormattedID,Name,ScheduleState,Description,Attachments', 
      query: '(Name contains "release")' 
     }; 
     rallyDataSource.findAll(queryObject, populateTable); 
     } 

     function populateTable(results) { 
     var tableDiv = document.getElementById('aDiv'); 
     var config = { columns: 
      [{key: 'FormattedID', header: 'Formatted ID', width: 100}, 
      {key: 'Name', width: 400}, 
      {key: 'ScheduleState', header: 'Schedule State', width: 200}, 
      {key: 'Description', width: 800}, 
      {key: 'Attachments', header: 'Attachment Link', width: 200}]}; 
     var table = new rally.sdk.ui.Table(config); 

    table.addRows(results.stories); 
     table.display(tableDiv); 

     }; 
     itemQuery(); 
    } 

    rally.addOnLoad(tableExample); 
    </script> 
</head> 
<body> 
    <div id="aDiv"></div> 
</body> 
</html> 

答えて

1

私は、各添付ファイルのオブジェクトIDを引くために、いくつかの後処理を行い、関連するテーブルのカラムに更新されているいくつかのHTMLリンクにそれをドロップし、あなたのアプリケーションのサンプルを少し変更したバージョンを含めています。

 <html> 
     <head> 
      <title>Table</title> 
      <meta name="Name" content="App Example: Stories with Attachments" /> 
      <meta name="Version" content="2010.4" /> 
      <meta name="Vendor" content="Rally Software" /> 
      <script type="text/javascript" src="https://rally1.rallydev.com/apps/1.29/sdk.js"></script> 
      <script type="text/javascript"> 

      var table = null; 

      function tableExample() { 
       var rallyDataSource = new rally.sdk.data.RallyDataSource('__WORKSPACE_OID__', 
                        '__PROJECT_OID__', 
                        '__PROJECT_SCOPING_UP__', 
                        '__PROJECT_SCOPING_DOWN__'); 
       function itemQuery() { 
       var queryObject = { 
        key: 'stories', 
        type: 'HierarchicalRequirement', 
        fetch: 'FormattedID,Name,ScheduleState,Description,Attachments,ObjectID' 
        // query: '(Name contains "release")' 
       }; 
       rallyDataSource.findAll(queryObject, populateTable); 
       } 

       function populateTable(results) { 

        if (table) { 
         table.destroy(); 
        } 

       var tableDiv = document.getElementById('aDiv'); 

       var config = { 'columnKeys' : ['FormattedID', 'Name', 'ScheduleState', 'Attachments'], 
           'columnHeaders' : ['FormattedID', 'Name', 'ScheduleState', 'Attachments'], 
           'columnWidths' : ['100px',  '400px', '85px',   '300px'] 
           }; 
       table = new rally.sdk.ui.Table(config); 
       table.addRows(results.stories); 

       for (i=0;i<results.stories.length;i++) { 

        myStory = results.stories[i]; 
        myAttachments = results.stories[i].Attachments; 

        myAttachmentHTML = ""; 
        for (j=0;j<myAttachments.length;j++) { 
         myAttachmentOID = myAttachments[j].ObjectID; 
         myAttachmentName = myAttachments[j].Name; 
         myAttachmentURL = "https://rally1.rallydev.com/slm/attachment/"+ 
           myAttachmentOID + "/" + myAttachmentName; 

         myAttachmentHTML += "<div><a href='" + myAttachmentURL + "'>" + 
           myAttachmentName + "</a></div>"; 

        } 
        table.setCell(i, 3, myAttachmentHTML); 
       } 
       table.display(tableDiv); 

       }; 
       itemQuery(); 
      } 

      rally.addOnLoad(tableExample); 
      </script> 
     </head> 
     <body> 
      <div id="aDiv"></div> 
     </body> 
     </html> 
+0

あなたは素晴らしいです!それは、おかげで、ありがとう。 –

+0

このメソッドは、rally.sdk.util.Context.getServerInfo()。getSlmUrl()が、Rallyサーバー自体のURLを取得するために、よりエレガントでサポートされた方法であることを指摘する必要があります。私が投稿した例 –