开发者

MvcContrib Grid - AutoGenerateColumns possible with complex objects?

开发者 https://www.devze.com 2022-12-30 00:48 出处:网络
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

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

精彩评论

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