ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
GridChooseColumns in .NET, Core could not find property (key)
Title:
B
I
{code}
?
I follow your http://demo.aspnetawesome.com/GridChooseColumnsDemo demo for setting columns server side (with entity framework core and .net core 2) I made a sample with 2 grids 1 "normal" and 1 with server side column setting, this a source about second: public ActionResult Dyn2GetItems(GridParams g) { var columns = new[] { new Column { Bind = "Id", Width = 70, Sortable = true, Order = 1 }, new Column { Bind = "LoginName", Sortable = true, Order = 2 } }; //first load if (g.Columns.Length == 0) { g.Columns = columns; } var gridModel = new GridModelBuilder<LoginLogEntity>(db.LoginLogs.AsQueryable(), g) { Map = o => new { o.Id, o.LoginName} }.Build(); return Json(gridModel); } view: @(Html.Awe().Grid("GridChooseColumns") .Url(Url.Action("Dyn2GetItems", "RegistryGrid")) .Persistence(Persistence.Session) .ColumnsPersistence(Persistence.Session) .ShowGroupBar(true) .SendColumns(true)) in second grid when click a column to order give me this error : "Could not find property [loginName] on type [LoginLogEntity]. Make sure you specify Key and Column.Bind correctly." (why search [loginName] with l in lowercase ?) PS: if I run the same project in a MVC5 project run correctly
Save Changes
Cancel
Meccanica Rossi
asked at 18 Jan 2018
Answers
B
I
{code}
?
I can't see anywhere in your code the `Key` being set, however since you're mentioning that this works in MVC5 and in .net core you're asking about lowercase, I'm guessing that the problem might be this: https://github.com/aspnet/Mvc/issues/4283 In asp.net core by default json serialisation will transform properties to camelCase instead of leaving them as they are. in the controller you should be able to set `g.Key` you can also try this: services .AddMvc() .AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());
Save Changes
Cancel
Omu
answered at 18 Jan 2018
Yes, run ! Thank You
at 18 Jan 2018
Meccanica Rossi
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