开发者

MvcContrib Grid - AutoGenerateColumns possible with complex objects?

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);
            }
        }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜