ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Grid - Cancellation Token support
Title:
B
I
{code}
?
Is it possible that a Grid can send a CancellationToken if the view is changed before the results are back from the server? This would be great for debugging purposes.
Save Changes
Cancel
Benjamin Meixner
asked at 10 Feb 2022
Answers
B
I
{code}
?
you could use a CancellationToken with the grid like this: public async Task<IActionResult> LunchesGrid(GridParams g, CancellationToken token) { var query = myCx.Lunches.AsQueryable(); var gmb = new GridModelBuilder<Lunch>(query, g) { KeyProp = o => o.Id, Map = o => new { o.Id, o.Person, ChefName = o.Chef?.FirstName + " " + o.Chef?.LastName, CountryName = o.Country?.Name }, }; query = gmb.OrderBy(query); gmb.ItemsCount = await query.CountAsync(token); gmb.PageItems = await gmb.GetPage(query) .Include(o => o.Chef) .Include(o => o.Country) .ToArrayAsync(token); var model = await gmb.BuildAsync(); return Json(model); }
Save Changes
Cancel
Omu
answered at 10 Feb 2022
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK