Hi,
the URL Adapter is not working as expected with the demo and docs.
List Binding is working just fine but the Data is not shown with URL-Adapter:
Here is the Function:
public ActionResult Get(DataManagerRequest dm)
{
IEnumerable DataSource = _context.Movie.ToList();
DataOperations operation = new DataOperations();
List<string> str = new List<string>();
if (dm.Search != null && dm.Search.Count > 0)
{
DataSource = operation.PerformSearching(DataSource, dm.Search); //Search
}
if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting
{
DataSource = operation.PerformSorting(DataSource, dm.Sorted);
}
if (dm.Where != null && dm.Where.Count > 0) //Filtering
{
DataSource = operation.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator);
}
int count = DataSource.Cast<Movie>().Count();
if (dm.Skip != 0)
{
DataSource = operation.PerformSkip(DataSource, dm.Skip); //Paging
}
if (dm.Take != 0)
{
DataSource = operation.PerformTake(DataSource, dm.Take);
}
return dm.RequiresCounts ? Json(new { result = DataSource, count = count }) : Json(DataSource);
}
I remember that i used to have some settings regarding JSON in my StartUp.CS
Do you have an working example for .NET Core 6 MVC?
Best regards!
|
public void ConfigureServices(IServiceCollection services)
{
...
services.AddMvc().AddJsonOptions(o =>
{
o.JsonSerializerOptions.PropertyNamingPolicy = null;
o.JsonSerializerOptions.DictionaryKeyPolicy = null;
});
} |
Hi Sujith,
This is the reply from the function:
[{"Id":1,"Title":"When Harry Met Sally","ReleaseDate":"1989-02-12T00:00:00","Genre":"Romantic Comedy","Price":1700.00},{"Id":2,"Title":"Ghostbusters ","ReleaseDate":"1984-03-13T00:00:00","Genre":"Comedy","Price":8.99},{"Id":3,"Title":"Ghostbusters 2","ReleaseDate":"1986-02-23T00:00:00","Genre":"Comedy","Price":9.99},{"Id":4,"Title":"Rio Bravo","ReleaseDate":"1959-04-15T00:00:00","Genre":"Western","Price":3.99}]
Looks like PascalCase for me. But the Grid is still not working.
FYI: .Net Core 6 does not have a Startup.CS anymore. But i could do the configuration within the Program.cs
builder.Services.AddMvc().AddJsonOptions(o =>
{
o.JsonSerializerOptions.PropertyNamingPolicy = null;
o.JsonSerializerOptions.DictionaryKeyPolicy = null;
});
But that didnt help here :(
Maybe this can help you?
Best regards,
Mark
Hi Pavithra,
After i did everything the same way you did i finally saw that your request Required the count and mine didnt
->
public ActionResult Get([FromBody] DataManagerRequest dm)
The [FromBody] was the missing part! After i added this - its working now.
Thanks and best regards,
Mar