ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Grid header to Sort cause an error on any column
Title:
B
I
{code}
?
I get this error when I try to sort a column in my Crud Grid and I get this error: Any idea causing this. Thanks in advance EventEve identity: public abstract class EntityBaseWithTypedId<TEntityId> : ValidatableObject, IEntityWithTypedId<TEntityId> { #region Implements IEntityWithTypedId<TEntityId> [NotMapped] public TEntityId Id { get; set; } #endregion } } public abstract class EntityBase : EntityBaseWithTypedId<Guid> { } public class EventEve : EntityBase { #region Properties public Guid IdEve { get; set; } public Guid IdTypeRefEve { get; set; } public decimal EventId { get; set; } public string EventCode { get; set; } public string EventName { get; set; } public decimal EventTypeId { get; set; } public string IsActiveFlag { get; set; } public DateTime CreatedDateEve { get; set; } public DateTime UpdatedDateEve { get; set; } public ObjectReferenceRef IdTypeRefEveNavigation { get; set; } public ICollection<EventOfficeEvo> EventOfficeEvo { get; set; } public ICollection<MetricValueMev> MetricValueMev { get; set; } public ICollection<MetricsMappingMma> MetricsMappingMma { get; set; } #endregion #region Constructors public EventEve() { EventOfficeEvo = new HashSet<EventOfficeEvo>(); MetricValueMev = new HashSet<MetricValueMev>(); MetricsMappingMma = new HashSet<MetricsMappingMma>(); } } } EventController: public ActionResult GridGetItems(GridParams g, string search) { search = (search ?? "").ToLower(); var items = _eveService.GetAll() .Where( x => x.EventCode.Contains(search) || x.EventName.Contains(search) ) .ToList().AsQueryable(); var firstOrDefault = items.FirstOrDefault(); if (firstOrDefault != null) { var guid = items.Any() ? firstOrDefault.Id : Guid.Empty; if (!string.IsNullOrEmpty(g.Key)) guid = Guid.Parse(g.Key); var model = new GridModelBuilder<EventEve>(items, g) { Key = "Id", // needed for api select, update, tree, nesting, EF GetItem = () => items.FirstOrDefault(x => x.Id == guid), // called by the grid.api.update ( edit popupform success js func ) Map = MapEntityToGridModel }.Build(); return Json(model); } return Json(""); } #endregion protected override object MapEntityToGridModel(EventEve o) { var eve = new { Id = o.IdEve, EventTypeIdEve = o.IdTypeRefEveNavigation?.ValueRef, EventCodeEve = o.EventCode, EventNameEve = o.EventName, EventIdEve = o.EventId, IsActiveEve = o.IsActiveFlag, CreatedEve = o.CreatedDateEve.ToShortDateTimeString(), UpdatedEve = o.UpdatedDateEve.ToShortDateTimeString() }; return eve; } Index.cshtml: <div class="h2" localize>EventList</div> @Html.InitCrudPopupsForGrid("EveGrid", "Event") <div class="bar"> `<button type="button" onclick="awe.open('createEveGrid')" class="awe-btn mbtn"><span localize>Create</span></button> </div> @(Html.Awe().Grid("EveGrid") .Mod(o => o.PageInfo().ColumnsSelector().ColumnsAutohide()) .Url(Url.Action("GridGetItems", "Event")) .Resizable() .Groupable(false) .Paging(true) .PageSize(30) .Reorderable() .Height(350) .Columns( new Column { Bind = "Id", Width = 55, Hidden = true }, new Column { Header = Localizer["EventCode"], Bind = "EventCodeEve" }.Mod(o => o.Nohide()), new Column { Header = Localizer["EventName"], Bind = "EventNameEve" }.Mod(o => o.Nohide()), new Column { Header = Localizer["EventId"], Bind = "EventIdEve" }.Mod(o => o.Nohide()), new Column { Header = Localizer["EventTypeId"], Bind = "EventTypeIdEve" }.Mod(o => o.Nohide()), new Column { Header = Localizer["IsActive"], Bind = "IsActiveEve" }.Mod(o => o.Nohide()), new Column { Header = Localizer["Created"], Bind = "CreatedEve" }.Mod(o => o.InlineReadonly()), new Column { Header = Localizer["Updated"], Bind = "UpdatedEve" }, new Column { ClientFormat = GridUtils.EditFormatForGrid("EveGrid"), Width = 50 }.Mod(o => o.Nohide()), new Column { ClientFormat = GridUtils.DeleteFormatForGrid("EveGrid"), Width = 50 }.Mod(o => o.Nohide())))` Error: *ArgumentNullException: Value cannot be null. Parameter name: member System.Linq.Expressions.Expression.MakeMemberAccess(Expression expression, MemberInfo member) Omu.AwesomeMvc.DynamicQuery.Dlinq.ParseSelector<T>(string prop, out Type endPropType) Omu.AwesomeMvc.DynamicQuery.Dlinq.OrderBy<T>(IQueryable<T> source, String[][] orderRules) Omu.AwesomeMvc.GridModelBuilder.BuildModel() Omu.AwesomeMvc.GridModelBuilder.Build() GrrDev2.Web.Controllers.EventController.GridGetItems(GridParams g, string search) in EventController.cs*
Save Changes
Cancel
vRITHNER
asked at 04 Aug 2017
The model defined in `GridModelBuilder<Model>` is the one that is used for databinding http://aspnetawesome.com/learn/mvc/Grid#Data-binding not the one returned from `Map`
at 04 Aug 2017
Omu
Answers
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