I am trying to dynamically create filters for a rallycardboard by using a QueryFilter object. I first create an array of QueryFilter that contains filtering on one property/value pair. I then check some other fields for values in order to decide whether to add those properties to the QueryFilter. However, it seems that after creation, even though I am able to access the object, it refuses to be appended to.
Here is an example of how it's structured:
var filters = [Ext.create('Rally.data.QueryFilter', {
property: 'attr1',
operator: '=',
value: this.attr1
})];
if (this.attr2 !== "") {
filters[0].and(Ext.create('Rally.data.QueryFilter', {
property: 'attr2',
operator: '=',
value: this.attr2
}));
}
if (this.attr3 !== "") {
filters[0].or(Ext.create('Rally.data.QueryFilter', {
property: 'attr3',
operator: '=',
value: this.attr3
}));
}
It looks like the object returned has to be reassigned inside of an array, like such:
var filters = [Ext.create('Rally.data.QueryFilter', {
property: 'attr1',
operator: '=',
value: this.attr1
})];
if (this.attr2 !== "") {
filters = [filters[0].and(Ext.create('Rally.data.QueryFilter', {
property: 'attr2',
operator: '=',
value: this.attr2
}))];
}
if (this.attr3 !== "") {
filters = [filters[0].or(Ext.create('Rally.data.QueryFilter', {
property: 'attr3',
operator: '=',
value: this.attr3
}))];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With