使用OR和and运算符的Rally应用程序筛选器示例



我想使用一个结合OR和and运算符的筛选器,但此筛选器语法仅使用and运算符:

this.grid = this.add({
                            xtype: 'rallygrid',
                            model: model,
                            columnCfgs: [
                                'FormattedID',
                                'Name',
                                'Priority',
                                'State'
                            ],
                            storeConfig: {
                                filters: [
                                    {
                                        property: 'Priority',
                                        operator: '=',
                                        value: 'High Attention'
                                    },
                                    {
                                        property: 'Priority',
                                        operator: '=',
                                        value: 'Normal'
                                    },
                                   {
                                        property: 'State',
                                        operator: '=',
                                        value: 'Open'
                                    }
                                ]
                            }
                        });

如果过滤器必须混合使用AND和OR运算符,则需要使用Rally.data.QueryFilter的和/或方法来构建它。这里有一个完整的例子,我在"高注意力"或"打开"状态下过滤"正常"优先级缺陷:

    Rally.onReady(function () {
    Ext.define('CustomApp', {
    extend: 'Rally.app.App',
    componentCls: 'app',
            launch: function() {
                Rally.data.ModelFactory.getModel({ 
                    type: 'Defect',
                    success: function(model) {
                        var filter = Ext.create('Rally.data.QueryFilter', {
                            property: 'Priority',
                            operator: '=',
                            value: 'Normal'
                        });
                        filter = filter.or({
                            property: 'Priority',
                            operator: '=',
                            value: 'High Attention'  
                        });
                         filter = filter.and({
                            property: 'State',
                            operator: '=',
                            value: 'Open'
                        });
                        filter.toString();
                        this.grid = this.add({
                            xtype: 'rallygrid',
                            model: model,
                            columnCfgs: [
                                'FormattedID',
                                'Name',
                                'Priority',
                                'State'
                            ],
                            storeConfig: {
                                filters : [filter]
                            }
                        });
                    },
                    scope: this
                });
            }
       });

        Rally.launchApp('CustomApp', {
            name:"MyApp"
        });

});

最新更新