-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.net core 2.0 JsonDataTable ? #22
Comments
Here is what I did. I created this method in the bottom of my controller: private JsonResult GenerateDataTableResponse<T>(int draw, IPagedList<T> model)
{
return new JsonResult(new
{
draw = draw,
recordsTotal = model.TotalCount,
recordsFiltered = model.TotalCount,
data = model
});
} Then I made my actions like this: [Produces("application/json")]
[HttpGet("{id}/entries")]
public async Task<IActionResult> Entries(Guid id, [FromQuery(Name = "draw")] int draw)
{
// Getting my entries. The variable entries is an instance of IQueryable<T> where T in my case is EntryViewModel.
var request = new DataTablesRequest<EntryViewModel>(Request.QueryString.ToString());
var filtered = entryViewModels.ToPagedList(request);
return GenerateDataTableResponse(draw, filtered);
} |
By the way, if you would like a .NET Core-compatible version of the library you should checkout this NuGet package: https://github.com/sebastianbk/DataTables.Queryable.Core |
Latest versions (since 1.7.0) of the library support .Net Core 2.0. Please check the: https://www.nuget.org/packages/DataTables.Queryable |
returning JsonDataTable doesn't work in .net core any workaround?
The text was updated successfully, but these errors were encountered: