0

I'm trying to do filtering function for KendoUI Grid.

Kendo sends data as form-data:

take:20
skip:0
page:1
pageSize:20
filter[filters][0][operator]:eq
filter[filters][0][value]:abc
filter[filters][0][field]:No
filter[logic]:and

I tried to deserialize it using dto:

public class FilteringRule
{
    public string Field { get; set; }
    public string Operator { get; set; }
    public string Value { get; set; }
}

public class FilteringInfo
{
    public string Logic { get; set; }
    public FilteringRule[] Filters { get; set; }
}

public class FilteredQuery
{
    FilteringInfo Filter { get; set; }
    //...
}

but deserialization fails:

'filter[filters][0][operator]' does not exist on type 'FilteredQuery'
'filter[filters][0][value]' does not exist on type 'FilteredQuery'
'filter[filters][0][field]' does not exist on type 'FilteredQuery'
'filter[logic]' does not exist on type 'FilteredQuery'

How to make this work? When I manually send json instead of form-data it works.

Can kendo send json? Setting contentType: "application/json" in datasource doesn't help. Kendo still sends data as form-data, servicestack throws error: "unable to bind request".

smokeing
  • 259
  • 1
  • 3
  • 13

1 Answers1

1

ServiceStack allows sending complex objects via QueryStrings using the lightweight JSV Syntax which from your example would look something like:

?filter={filters:[{operator:eq,value:abc,field:no}],{logic:and}}

But since Kendo is unlikely to support this syntax, you would be better off sending JSON if it supports it which would naturally map to your DTOs.

mythz
  • 141,670
  • 29
  • 246
  • 390