javascript - 数据未根据迭代加载

标签 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);




},

});

最佳答案

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

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

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

我还认为您计算标签的代码也有点奇怪。您的循环需要遍历从商店返回的故事,然后您需要实际检查每个标签字段上的 _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;

这能让你更进一步吗?

关于javascript - 数据未根据迭代加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43200254/

相关文章:

javascript - FullPage.js 在 iExplore 中自动滑动

javascript - 简单的 Chrome 扩展但有问题吗?

javascript - 使用 JavaScript 显示复选框值

javascript - 如何在编译es2015库时将CSS注入(inject)javascript文件

css - 如何在调整窗口大小时使 Rally 单选按钮字段保持相同大小

javascript - 拉力赛标签云

python - 如何使用 Rally API 获取测试用例名称

Rally Rest API ....将缺陷添加到缺陷套件

c# - .Net Rally.RestApi 创建 Rally 测试文件夹时出现错误 "Not authorized to perform action: Invalid key"

javascript - 如果没有计时器,fitBounds 就无法工作