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

Sorting and filtering data based on the keyword in name

您好,我想要一个包含 2 个过滤器的函数,首先根据包含单词 "from mail" 的名称关键字过滤数据,然后根据迭代框过滤数据。我已尝试这样做,但网格未显示我使用的代码的数据:

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'
                                    }
                                ]
                            }
                        });

}

});

感谢您的帮助

你离得并不远——我认为你被 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());
    }
});

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