SDK 1中的Rally Query与SDK 2中的Store

Rally Query in the SDK 1 vs Store in the SDK 2

本文关键字:SDK 中的 Store Rally Query      更新时间:2023-09-26

我正在尝试为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

结果是

数据

格式Id 12345

Blah

前置

计数2

我需要的是

数据

格式Id 12345

Blah

前置

   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/#/指南/集合_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());
               }
           });
        }
    }
});

请注意,这将生成大量请求,因此最好通过过滤器限制根存储中的故事总数。