Question

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.

Was it helpful?

Solution

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);
            }
        }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top