数据未按迭代加载

时间:2017-04-04 06:54:00

标签: javascript rally

我在过滤器中选择了迭代,并尝试根据迭代加载数据,但仍然无法根据迭代提取数据,但它没有显示任何请求帮助。代码我用过

Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',

launch: function() {

    var filters = [];
    var timeboxScope = this.getContext().getTimeboxScope();

    if(timeboxScope) {
        filters.push(timeboxScope.getQueryFilter());
    }

    this.loaddata(filters);            
},

onTimeboxScopeChange: function(newTimeboxScope) {               
    var newFilters = [];
    var updatedTimeboxScope = this.getContext().getTimeboxScope();
    if (this.grid) {
        this.grid.destroy();
    }                   
    if (updatedTimeboxScope) {
        newFilters.push(newTimeboxScope.getQueryFilter());
    }
    this.loaddata(newFilters);
},

loaddata: function(queryFilters) {
    Ext.create("Rally.data.wsapi.Store",{
       model: 'UserStory', //or defectModel
fetch: ['Tags'],
StoreConfig:{

    filters: queryFilters
},
autoLoad: true,
listeners: {
    load: function(Store, records) {
        this._loadprocessdata(records);
    },
    scope: this
}

}); },

_loadprocessdata: function(gathered){

    var tags=[];
    tags=gathered;
    var i=0;
    var interrupt=0;
    var other=0;
    var total=0;
    var percentage=0;
    for(i=0;i<tags.length;i++)
    {
        if(tags[i]==="Interrupt"){
            interrupt++;

        }
        else{
            other++;

        }


    }   

            total = other + interrupt;
            percentage = (interrupt/total)*100;

    var TagSummaryStore = Ext.create("Ext.data.Store",{
        fields:['tagName', 'other', 'total', 'percentage'],
                proxy: {
                    type: 'memory',
                    reader: {
                        type: 'json',
                        root: 'items'
                    }
                }
            });


            TagSummaryStore.add( {
                'tagName'   : tags.length,
                'others' : other,
                'Total'  : tags.length,
                'Percentage' :  percentage.toFixed()
            } );


        //Counting Tags and Visualize by Table
        var myGrid=Ext.create("Ext.grid.Panel",{
                title: 'Tag Summary',
                store: TagSummaryStore,
                columns: [
                    { text: 'Tag', dataIndex: 'tagName' },
                    { text: 'Stories', dataIndex: 'other' },
                    { text: 'Points', dataIndex: 'Total' },
                    { text: '%', dataIndex: 'Percentage' }
                ],
                renderTo: Ext.getBody()
            }
        );
        this.add(myGrid);




},

});

1 个答案:

答案 0 :(得分:0)

我认为您的过滤器未被尊重的原因是因为它们需要直接传递到商店,而不是StoreConfig:

Ext.create("Rally.data.wsapi.Store", {
   model: 'UserStory', //or defectModel
   fetch: ['Tags'],
   filters: queryFilters,

   //rest of store config here...
});

我也认为你计算标签的代码也有点奇怪。你的循环需要覆盖从商店返回的故事,然后你需要在每个Tags字段上实际检查_tagsNameArray。

var interrupt=0;
var other=0;
_.each(gathered, function(story) {
    var tagNames = _.pluck(story.get('Tags')._tagsNameArray, 'Name');
    if(_.contains(tagNames, 'Interrupt')) {
        interrupt++;
    } else {
        other++;
    }
});

var total = other + interrupt;
var percentage = (interrupt/total)*100;

这会让你更进一步吗?