views:

185

answers:

1

I like MvcContrib Grid's AutoGenerateColumns feature, however it only seems to work with simple objects. Is it possible to get it to traverse the 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.

+2  A: 

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);
            }
        }
jfar
Fair enough ;) Thanks.
UpTheCreek