Multiple filters on same field not working

7 posts, 0 answers
  1. Martin
    Martin avatar
    1 posts
    Member since:
    Aug 2014

    Posted 31 Oct 2014 Link to this post

    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?
  2. Anton Dobrev
    Admin
    Anton Dobrev avatar
    558 posts

    Posted 03 Nov 2014 Link to this post

    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.
     
  3. Martin
    Martin avatar
    1 posts
    Member since:
    Jul 2014

    Posted 02 Jan 2015 in reply to Anton Dobrev Link to this post

    Any news for this bug? Do you know when it will be fixed?
  4. Anton Dobrev
    Admin
    Anton Dobrev avatar
    558 posts

    Posted 06 Jan 2015 Link to this post

    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.
     
  5. Calin
    Calin avatar
    9 posts
    Member since:
    Feb 2016

    Posted 26 Dec 2016 in reply to Anton Dobrev Link to this post

    Hello Anton, 

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

    Thanks,

    CalinC

  6. Calin
    Calin avatar
    9 posts
    Member since:
    Feb 2016

    Posted 26 Dec 2016 in reply to Calin Link to this post

    fyi, I'm trying it into a hybrid mobile app.
  7. Anton Dobrev
    Admin
    Anton Dobrev avatar
    558 posts

    Posted 27 Dec 2016 Link to this post

    @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.
     
Back to Top