ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Grid is not displaying child object properties
Title:
B
I
{code}
?
My controller GetItems returns the object correctly (with nested child objects). But in the ui, the grid does not display the nested child field. @Html.Awe().Grid("LessonsGrid").Url(Url.Action("GetItems","Lesson")).Columns( new Column{Name = "Id", Width = 55}, new Column { Name = "Topic.Name", Width = 30 }, new Column { Name = "Topic.Level.Name", Width = 30 }, new Column{Name="Topic.Subject.Name",Width = 100}, new Column{Name="LessonTypeId", Width = 100}, new Column{ClientFormat = EditFormat, Width = 50}, new Column{ClientFormat = DeleteFormat, Width = 50 } ).Parent("txtSearch","search") When I inspect the list being returned from GetItems, I can see Lesson>Topic>Subject>Name and Lesson>Topic>Level>Name and Topic>Name But they are not being displayed on the grid. What am i doing wrong/
Save Changes
Cancel
vishal.khoodeeram
asked at 08 Oct 2014
Answers
B
I
{code}
?
it's not supposed to work this way, the Column.Name is used for binding the column mainly (for sorting, grouping) but also gives a default to ClientFormat = .Name if you have . or , in the Name you need to use Map in the GetItems and ClientFormat in the View as shown on this page: http://demo.aspnetawesome.com/GridDemo note in the controller we have the map: Map = o => new { ... CountryName = o.Country.Name, ChefName = o.Chef.FirstName + " " + o.Chef.LastName } and in the view we have this: new Column{Name = "Country.Name", ClientFormat = ".CountryName", Header = "Country"}, new Column{Name = "Chef.FirstName,Chef.LastName", ClientFormat = ".ChefName", Header="Chef"}
Save Changes
Cancel
Omu
answered at 08 Oct 2014
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