根据名称中的关键字对数据进行排序和过滤

时间:2017-04-25 03:11:09

标签: rally

您好我希望有一个函数首先包含2个过滤器,根据名称的关键字过滤数据,该关键字包含单词"来自邮件"而下一个是基于迭代框。我试过这样做,但网格显示我使用的代码没有数据:

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

launch: function() {

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

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

    this.getFilteredStoryModel(filters);            
},

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

Ext.create('Rally.data.wsapi.Store', {
fetch: ['FormattedID','Name','Owner','ScheduleState'],
model:"User Story",
            filters: queryFilters,
            autoLoad:true,
            listeners:{
                load:function(myStore,myData,success){
                    console.log("got data:",myStore,myData,success);
                    //the data is got and store in myStore if success. and the _loadTagSummary is called with the myStore pass into it
                    this.displaydata(myStore);
                },
                scope:this
            },
    }); 
},
displaydata:function(mystorystore){
         this.grid = this.add({
                            xtype: 'rallygrid',
                            model: mystorystore,
                            columnCfgs: [
                                'FormattedID',
                                'Name',
                                'Owner'
                            ],
                            storeConfig: {
                                filters: [
                                    {
                                        property: 'Name',
                                        operator: '=',
                                        value: 'From Mail'
                                    }
                                ]
                            }
                        });

}

});

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

你不是太远了 - 我认为你被onTimeboxScopeChange中的一个微妙的错误(没有调用父方法)绊倒了,还有一些奇怪的想法在网格上同时指定商店和storeConfig。

以下是我提出的建议:

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

    layout: 'fit', //take up all available space

    launch: function() {
        this._addGrid();            
    },

    onTimeboxScopeChange: function(newTimeboxScope) { 
        this.callParent(arguments); //super important, or timebox scope in context doesn't ever get updated!

        this._refreshGrid();
    },

    _addGrid: function() {
        this.add({
            xtype: 'rallygrid',
            model: 'User Story',
            columnCfgs: [
                'FormattedID',
                'Name',
                'Owner'
            ],
            storeConfig: {
                filters: this._getFilters()
            }
        });
    },

    _getFilters: function() {
        var filters = [
            {
                property: 'Name',
                operator: '=',
                value: 'From Mail'
            }
        ];

        var timeboxScope = this.getContext().getTimeboxScope();                   
        if (timeboxScope) {
            filters.push(timeboxScope.getQueryFilter());
        }

        return filters;
    },

    _refreshGrid: function() {
        var grid = this.down('rallygrid'),
            store = grid.getStore();

        store.clearFilter(true);
        store.filter(this._getFilters());
    }
});

我在文档中使用了一些不同的示例来帮助解决这个问题: