Matt Harutun
Matt Harutun

Reputation: 139

Rally App Filter Example using OR and AND operators

I would like to use a filter that combines OR and AND operator, but this filter syntax uses AND operator only:

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

                            }
                        });

Upvotes: 0

Views: 1324

Answers (1)

nickm
nickm

Reputation: 5966

If the filter has to use a mix of AND and OR operators you'll need to build it using and/or methods of Rally.data.QueryFilter . Here is a full example where I filter in "High Attention" or "Normal" priority defects in "Open" State:

    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"
        });

});

Upvotes: 1

Related Questions