Grid with list count property column
Id | Person | Food | MealsCount | Meals | Location |
3675 | Mary | Shepherd's pie | 2 | Wheat, Papaya | Diner |
3671 | Jeremy | Pizza | 1 | Hazelnuts | Tavern |
3667 | John | Cheesecake | 2 | Walnuts, Broccoli | Restaurant |
3663 | Michael | Hot Beverage | 2 | Potato, Broccoli | Visit |
3659 | Gabrielle | French toast | 2 | Papaya, Tomato | Tavern |
3655 | Lucy | Big Salad | 3 | Broccoli, Banana, Tomato | Tavern |
3651 | Cheyenne | Big Salad | 1 | Rice | Visit |
3647 | Jonah | Shepherd's pie | 3 | Oats, Banana, Papaya | Visit |
3643 | Fernando | Soup | 1 | Rice | University |
3639 | Audrey | Shepherd's pie | 1 | Rice | University |
In this demo we show how you can have a count property in the grid, while also being able to sort and group by that property.
For this to work you need to add a get only property to your Entity (Lunch in our case
However if you're using EntityFramework you'll also need to set the
For this to work you need to add a get only property to your Entity (Lunch in our case
public int MealsCount => Meals.Count();
),
after this you can use the count property as any other property.
However if you're using EntityFramework you'll also need to set the
OrderByFunc
on the GridModelBuilder
.
Comments