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

Binding complex querystring to a C# model (ASP.NET Core 3.1)

1 Answer 324 Views
Grid
This is a migrated thread and some comments may be shown as answers.
n/a
Top achievements
Rank 1
n/a asked on 11 Jan 2021, 09:57 PM

Dear all,

I'm using Kendo UI for JQuery and would like to bind the following querystring (generated by default from the grid widget):

skip=0&page=1&filter[filters][0][value]=Rare Diseases&filter[filters][0][operator]=eq&filter[filters][0][field]=keyword1.keywordValue&filter[logic]=or

to this model of an ASP.NET Core 3.1 webapp:

 

public class FSP
{
    [JsonProperty("take")]
    public int Take { get; set; }
 
    [JsonProperty("skip")]
    public int Skip { get; set; }
 
    [JsonProperty("page")]
    public int Page { get; set; }
 
    [JsonProperty("pageSize")]
    public int PageSize { get; set; }
 
    [JsonProperty("filter")]
    public Dictionary<string,IEnumerable<Dictionary<string, string>>> Filter { get; set; }
}

 

All parameters of querystring are correctly mapped, except filter. Furthermore, I would like to avoid changing the querystring using the function transport.parameterMap.

Could you help me to find the error?

Thank you in advance.

Filippo

 

 

1 Answer, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 13 Jan 2021, 01:25 PM

Hello Filippo Santoro,

The easiest option will be to use our DataSourceRequest binder which will bind the query string to a DataSourceRequest model. You can find more about that in the following article:

Another option would be to create a filter Model and specify to which value each property binds using model binding.

I hope this helps.

Regards,
Georgi
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
n/a
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Share this question
or