Alter Uri sended from kendo grid to server for filtering (odata v4)

7 posts, 1 answers
  1. Goran
    Goran avatar
    3 posts
    Member since:
    Mar 2015

    Posted 17 Mar 2015 Link to this post


    We have following model which are bind to kendo grid with web api 2.2 and Odata v4.0

    public class Order
    {
        public int Id {get;set;}
        public ICollection<User> ApprovedByUsers {get;set;}
    }
     
    public class User
    {
        public string Name {get;set;}
        public string Company {get;set; }
    }


    For ApprovedByUsers property we use custom template to display data in grid column in format:

    Name1 (company1)
    Name 2 (Company2)

    All columns have filterable row for filtering it.

    When user input some text in filter column kendo grid generate folowing request:

    GET /odata/documents?%24top=20&%24filter=contains(ApprovedByUsers%2C%27WMS%27)&%24count=true&myDocumentsOnly=true

    which throws following errors:

    The argument for an invocation of a function with name 'tolower' is not a single value. All arguments for this function must be single values.

    We need to alter this request so that following request has to be send:

    odata/documents?%24filter=AssignedUsers/any(d:d/CompanyNameExternalUser eq 'WMS')&%24count=true&myDocumentsOnly=false

    We are using kendo controls version: 2014.3.1411

    How we can do it?
  2. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 19 Mar 2015 Link to this post

    Hello Goran,

    If I understand you correctly you have bound the Grid to a collection/array of Order objects and you want to filter by some nested collection called ApprovedByUsers which is collection/array of User objects. Is this correct?

    If this is the case I am afraid it is not possible to filter by nested array field, the Grid / DataSource does not support such scenario for nesting.

    In case you have bound the Grid directly to the ApprovedByUsers array, then you should be able to filter by Name or Company as expected.

    Kind Regards,
    Petur Subev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Goran
    Goran avatar
    3 posts
    Member since:
    Mar 2015

    Posted 19 Mar 2015 in reply to Petur Subev Link to this post

    Hello Mr. Subev,

       You understood me correctly and thank You for answer.

    Since I have to solve this is there a way that I can alter request (specifically filter) so it support odata-v4 query.

    I know about parameterMap function

    var paramMap = kendo.data.transports["odata-v4"].parameterMap(options);

    , but I'm not sure if this is correct "extension point" for me to change paramMap.filter?

    Also, my second option is that I can send one string field with the separator i.e  UserName1 (Company)^~UserName 2 (Company 2)~^ User name 3 (Company) ...and I was able to filter it. Issue with this is that aucomplete in row filter display string above.
    Is there a way that I can disable autocomplete feature in row filter, but keep filter feature.

    Kind Regards,
    Goran.



  5. Answer
    Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 20 Mar 2015 Link to this post

    Hello again Goran,

    Indeed the parameterMap is the most appropriate function to intercept and change the format in which the data is send to the server. However we do not have any sample that demonstrates the format which you need to use or how exactly you should alter the parameterMap result.

    e.g.

    kendoGrid({
         dataSource: {
                transport: {
                      parameterMap: function (data) {
                           var data = kendo.data.transport["odata-v4"].parameterMap(options);
                           //apply your changes to data object formatting
                           return data;
                      }
                }
         }
    })

    Yes you can disable the suggestions of the filter row. Same questions discussed here:

    http://www.telerik.com/forums/kendo-ui-grid-with-filter-row#yowC3LydX0CtW6yEPZYgYw

    Kind Regards,
    Petur Subev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. Goran
    Goran avatar
    3 posts
    Member since:
    Mar 2015

    Posted 20 Mar 2015 in reply to Petur Subev Link to this post

    Hello Mr. Subev,

      thank You for clarification.


    Kind Regards,
    Goran
  7. Jason
    Jason avatar
    22 posts
    Member since:
    Sep 2007

    Posted 17 Aug Link to this post

    I am facing a similar situation as the original problem and am wondering if there has been any update or any plans to implement filtering on nested arrays?
  8. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 19 Aug Link to this post

    Hello Jason,

    I'm afraid that filtering on arrays is still not supported.

    Regards,
    Rosen
    Telerik by Progress
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
Back to Top
Kendo UI is VS 2017 Ready