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

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

6 Answers 306 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Goran
Top achievements
Rank 1
Goran asked on 17 Mar 2015, 04:25 PM

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?

6 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 19 Mar 2015, 01:20 PM
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!
 
0
Goran
Top achievements
Rank 1
answered on 19 Mar 2015, 01:42 PM
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.



0
Accepted
Petur Subev
Telerik team
answered on 20 Mar 2015, 12:48 PM
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!
 
0
Goran
Top achievements
Rank 1
answered on 20 Mar 2015, 07:21 PM
Hello Mr. Subev,

  thank You for clarification.


Kind Regards,
Goran
0
Jason
Top achievements
Rank 1
answered on 17 Aug 2016, 07:43 PM
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?
0
Rosen
Telerik team
answered on 19 Aug 2016, 11:56 AM

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.
 
Tags
Grid
Asked by
Goran
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Goran
Top achievements
Rank 1
Jason
Top achievements
Rank 1
Rosen
Telerik team
Share this question
or