0

我想使用组合 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'
                                    }
                                ]

                            }
                        });
4

1 回答 1

1

如果过滤器必须混合使用 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"
        });

});

于 2013-06-26T17:58:46.523 回答