I like MvcContrib Grid's AutoGenerateColumns feature, however it only seems to work with simple objects. Is it possible to get it to traverse th开发者_Go百科e properties of a complex object? Or is it neccesary to do this manually with column.For()
?
An example would be a User object that has an Address object as one of its properties.
Nope. The grid only loops through a single layer of properties. MVCContrib Grid won't recursively drill down into your object.
If you look at the the source:
foreach(var property in modelMetadata.Properties)
{
if(!property.ShowForDisplay)
{
continue;
}
var column = For(PropertyToExpression(property));
if(!string.IsNullOrEmpty(property.DisplayName))
{
column.Named(property.DisplayName);
}
if(!string.IsNullOrEmpty(property.DisplayFormatString))
{
column.Format(property.DisplayFormatString);
}
}
精彩评论