I have relations one to many in DB ( i used entity interface to generate associations between 2 obj) Im getting error: Bound columns require a field or property access expression
My code:
in view:
Html.Telerik()
.Grid<Y.Orders.Models.Orders>("orders")
.Name("Orders")
.DataKeys(dataKeys => dataKeys.Add(o => o.Id))
//.Pageable(paging => paging.PageSize(20).Style(GridPagerStyles.PageSizeDropDown | GridPagerStyles.NextPreviousAndNumeric))
.Columns(columns =>
{
columns.Command(commands =>
{
commands.Custom("comments").ButtonType(GridButtonType.Text).Text("Szczegóły").Action("Index", "Komentarze");
});
columns.Bound(o => o.Tytul).Title("Title");
columns.Bound(o => o.Deliveries.Sum(m=>m.deliveryTime)).Title("Time of order");
})
.Filterable()
.Sortable(sort =>
{
sort.SortMode(GridSortMode.MultipleColumn); sort.OrderBy(ord =>
{
ord.Add(o => o.Time).Descending();
});
})
.Groupable(grouping => grouping.Groups(groups =>
{
groups.Add(c => c.Users.Firms.Name);
}))
.Render();
in entity model:
public ObjectSet<Deliveries> Deliveries
{
get
{
if ((_ Deliveries
== null))
{
_Deliveries = base.CreateObjectSet<Deliveries>("Deliveries");
}
return _Deliveries;
}
}
private ObjectSet<Deliveries> _Deliveries;
In deliveries i havnt any null.
Where is problem ?
columns.Bound accept only primitive as int or string. You can't aggregate or transform object as your example :
o.Deliveries.Sum(m=>m.deliveryTime)
You do create in Deliveries
object a parameter as this :
public int SumDeliveries
{
get { return this.Sum(m=>m.deliveryTime); }
}
and so you can bind this on grid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With