过滤选项:所有选择

时间:2014-06-23 19:40:56

标签: rally

我根据网格的状态创建了一个过滤器。但是,无论状态如何,我都无法找到一种方法来查看所有任务。有没有办法在过滤器中添加所有选项,以便显示来自所有状态的任务?这是我到目前为止的代码

                        xtype : 'rallyfieldvaluecombobox',
                        itemId : 'stateComboBox',
                        fieldLabel : 'Filter by State:',
                        model : 'task',
                        field : 'State',
                        listeners : {
                            select : this._onSelect1,
                            ready : this._onLoad1,
                            scope : this
                        }

1 个答案:

答案 0 :(得分:0)

这是一种做法。在这个组合框中,我设置allowNoEntry: true,并使用它代替" all"。选择NoEntry时,组合框返回null。我在_getStateFilter检查了这个条件。

如果组合框返回null,则_getStateFilter返回空过滤器,这有效地删除了State的所有过滤,并返回所有任务,而不管State值如何。

Ext.define('CustomApp', {
    extend: 'Rally.app.App',
    componentCls: 'app',
    launch: function() {
        this.add({
            xtype: 'rallyfieldvaluecombobox',
            itemId: 'stateComboBox',
            fieldLabel: 'Filter by State:',
            model: 'Task',
            field: 'State',
            allowNoEntry: true,
            listeners: {
                select: this._onSelect,
                ready: this._onLoad,
                scope: this
            }
        });
    },

    _onLoad: function() {
        this.add({
            xtype: 'rallygrid',
            columnCfgs: [
                'FormattedID',
                'Name',
                'State'
            ],
            context: this.getContext(),
            storeConfig:  {
                model: 'task',
                context: this.context.getDataContext(),
                filters: [this._getStateFilter()]
            }
        });
    },

    _getStateFilter: function() {
        if (!this.down('#stateComboBox').getValue()) {
            return {}
        }
        else{
            return {
            property: 'State',
            operator: '=',
            value: this.down('#stateComboBox').getValue()
        };
        }

    },

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

        store.clearFilter(true);
        store.filter(this._getStateFilter());
    }
});
相关问题