This is a migrated thread and some comments may be shown as answers.

Multiple filters on same field not working

6 Answers 105 Views
Bugs & Issues
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Martin
Top achievements
Rank 1
Martin asked on 31 Oct 2014, 03:31 PM
Filtering a kendo dataSource connected to everlive doesn't seem to work if you have a two filters on the same field/column like this:

[
   {field: "State", operator: "neq", value:"active"},
   {field: "State", operator: "neq", value:"new"}
]

This gets translated to an everlive filter that looks like this: X-Everlive-Filter:{"State":{"$ne":"new"}}

Seems like the first filter gets ignored. Using multiple filters on different fields works though.

Doing this on a normal kendo datasource (not everlive) works fine.

Am I doing something wrong or is this a bug?

6 Answers, 1 is accepted

Sort by
0
Anton Dobrev
Telerik team
answered on 03 Nov 2014, 12:17 PM
Hello Martin,

Thank you for reporting this. I can confirm that this is a bug in the "Everlive" dialect of the Kendo UI Data Source that will be addressed.

I updated your Telerik Points as a token of gratitude for your valuable input.

Let me know should you have any further questions or suggestions.

Regards,
Anton Dobrev
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
0
Martin
Top achievements
Rank 1
answered on 02 Jan 2015, 02:10 PM
Any news for this bug? Do you know when it will be fixed?
0
Anton Dobrev
Telerik team
answered on 06 Jan 2015, 10:48 AM
Hi Martin,

Thank you for getting back to us.

The bug is logged in our issue tracking system and will be addressed. However, at the current stage we cannot commit to a particular time-frame for the fix.

As a workaround I can suggest that you pass the filter to the transport.read.beforeSend configuration of the data source. Actually this is the configuration setting of the underlying AJAX request executed by jQuery.

You can also modify the request before creating, updating or deleting items.

For example:
var filterExpression = {
    "$and": [{
        "field1": {
            "$ne": "active"
        }
    }, {
        "field1": {
            "$ne": "new"
        }
    }]
};
 
var dataSource = new kendo.data.DataSource({
    type: 'everlive',
    transport: {
        typeName: 'Activities',
        read: {
            beforeSend: function(xhr) {
                xhr.setRequestHeader('X-Everlive-Filter', JSON.stringify(filterExpression));
            }
        }
    },
    schema: {
        model: {
            id: Everlive.idField
        }
    }
});

Thus you will be able to use a multiple filter on the same field.

I hope that this will be helpful for you.

Regards,
Anton Dobrev
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
0
Calin
Top achievements
Rank 1
answered on 26 Dec 2016, 10:40 PM

Hello Anton, 

I have just tried te solution but I get that setRequestHeader is undefined. Any thoughts?

Thanks,

CalinC

0
Calin
Top achievements
Rank 1
answered on 26 Dec 2016, 10:43 PM
fyi, I'm trying it into a hybrid mobile app.
0
Anton Dobrev
Telerik team
answered on 27 Dec 2016, 11:49 AM
@all

This bug was fixed in previous releases of the JavaScript SDK.

@Calin

If you need to set a custom filter via the header (like a GeoPoint filter) see the headers option for custom filtering (instead of setRequestHeader) as shown here.

Please note that the headers will be set only at the time of initializing the data source (as for the current design) but you can also modify the filtering header dynamically (if needed) via the beforeExecute event.

I hope this helps.

Regards,
Anton Dobrev
Telerik by Progress
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
Tags
Bugs & Issues
Asked by
Martin
Top achievements
Rank 1
Answers by
Anton Dobrev
Telerik team
Martin
Top achievements
Rank 1
Calin
Top achievements
Rank 1
Share this question
or