2012-04-30 93 views
2

我試圖找出一種方法來拉鍊接到用戶故事可能有的附件,但我還沒有能夠找出如何。就我所知,當用戶故事具有附件時,我在該列中唯一得到的是「[object Object]」。鏈接到附件

似乎沒有太多的抓取附件,如果任何人可以擺脫任何光線或指向正確的方向,我一定會很感激!

<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

我,包括你的App樣本略加修改的版本,做一些後期處理摳每一個附件的對象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()是一種更加優雅和支持的方式來獲取拉力賽服務器本身的URL,而不像硬編碼那樣我發佈的示例... – 2012-05-01 18:24:11