Your solution depends on the setup of you model. For example:
public class MyModel
{
[Key]
[DataMember]
public Guid Id { get; set; }
[DataMember]
public string Containername { get; set; }
[DataMember]
public Guid? ChildID { get; set; }
[DataMember]
public int? OtherListId { get; set; }
public virtual ChildModel Child { get; set; }
public virtual ICollection<OtherList> otherList { get; set; }
}
Then your grid would need to be setup as follows:
@vGrid.GetHtml(columns: vGrid.Columns(
vGrid.Column("ID", header: "ID"),
vGrid.Column("Child", header: "Raw Drive Label",
format: (item) => item.Child == null ? new MvcHtmlString("") : item.Child.ID),
vGrid.Column("otherList", header: "otherList", format: (item) =>
{
WebGrid subGrid = new WebGrid(source: item.otherList);
return subGrid.GetHtml(
htmlAttributes: new { id = "subT" },
columns: subGrid.Columns(subGrid.Column("Name")
)
);
})
))
Since "otherList" is an ICollection, or any type of list, you have to loop through it to display the data.
Add the following style to get rid of the table formatting in the internal table, to make it look like part of the external table:
#subT {
border: none;
padding: 0;
margin: 0;
}
/*don't show the table header:*/
#subT > thead {
display: none;
}
#subT > tbody td{
border: none;
}
Hope this helps!