簡體   English   中英

SDK 1中的Rally查詢與SDK 2中的存儲

[英]Rally Query in the SDK 1 vs Store in the SDK 2

我正在嘗試為Rally創建一個可導出到CSV網格的應用程序,以顯示依賴關系。 但我沒有得到使用商店的SDK 2所期望的結果。 我發現一個舊的SDK 1應用程序正在返回我想要的東西。

我不知道我該怎么做才能讓前輩們表現出來。 我所得到的只是數據對象中存儲的計數。 我已經看過文檔很多次了,我被困住了。

  var dependencydata = Ext.create('Rally.data.wsapi.Store', { model: 'hierarchicalrequirement', autoLoad: true, listeners: { load: function(dependencydata, data, success) { //process data console.log("Woot Data !",dependencydata, data, success); this.loadgrid(dependencydata); }, scope: this }, fetch: ['Rank','FormattedID','Name','Predecessors','Successors','Project','ScheduleState'] });//end Store 

結果是

數據

格式編號12345

布拉

前任

數2

我需要的是

數據

格式編號12345

布拉

前任

   object 

   Array

    FormatId 45637

我猜在SDK 1中會像這樣完成

 var queryConfig = { type : 'hierarchicalrequirement', key : 'stories', fetch: 'Rank,FormattedID,Name,Predecessors,Successors,Project,ScheduleState', query: '(Release.Name = "' + relDropdown.getSelectedName() + '")', order: 'Rank' }; rallyDataSource.findAll(queryConfig, showUserStoriesTable); } 

SDK 2使用的WSAPI v2.0不允許像v1.0那樣在一個請求中進行水合集合。

幸運的是,文檔中有一個指南可以處理這個確切的主題: https : //help.rallydev.com/apps/2.0/doc/#!/ guide/ collections_in_v2

您的案例稍微復雜一點,因為您需要為每個故事加載2個合集(前輩和后繼)

所以這樣的事情應該工作:

//keep track of all the pending collection loads
var promises = [];

Ext.create('Rally.data.wsapi.Store', {
    model: 'UserStory',
    fetch: ['Rank','FormattedID','Name','Predecessors','Successors','Project','ScheduleState'],
    autoLoad: true,
    listeners: {
        load: function(store, records) {              
           _.each(records, function(story) {
               //create the stores to load the collections
               story.predecessorStore = story.getCollection('Predecessors');
               story.successorStore = story.getCollection('Successors');

               //load the stores and keep track of the load operations
               promises.push(predecessorStore.load({fetch: ['FormattedID']}));
               promises.push(successorStore.load({fetch: ['FormattedID']}));
           });

           //wait for all promises to finish
           Deft.Promise.all(promises).then({
               success: function() {
                   //all data loaded.
                   console.log(records[0].predecessorStore.getRange());
                   console.log(records[0].successorStore.getRange());
               }
           });
        }
    }
});

請注意,這將生成大量請求,因此最好通過過濾器限制根存儲中的故事總數。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM