Closed erroric closed 11 years ago
great.. what to submit it as a pull request.. or does anyone else want to help out here? Eric Hexter
blog | http://Hex.LosTechies.com info | http://www.linkedin.com/in/erichexter
On Mon, Feb 25, 2013 at 1:12 PM, Локтионов Алексей <notifications@github.com
wrote:
Hi. ViewPropertiesExtensions.cs -> VisibleProperties() extension ignores DisplayAttribute "Order" property in models.
I have suggest simple solution for this:
public static PropertyInfo[] VisibleProperties(this IEnumerable Model) { var elementType = Model.GetType().GetElementType(); if (elementType == null) { elementType = Model.GetType().GetGenericArguments()[0]; } return elementType.GetProperties().Where(info => info.Name != elementType.IdentifierPropertyName()).OrderedByDisplayAttr().ToArray(); }
public static PropertyInfo[] VisibleProperties(this Object model) { return model.GetType().GetProperties().Where(info => info.Name != model.IdentifierPropertyName()).OrderedByDisplayAttr().ToArray(); } // Support for Order property in [Display()] attribute public static IOrderedEnumerable<PropertyInfo> OrderedByDisplayAttr(this IEnumerable<PropertyInfo> collection) { return collection.OrderBy(col => { var attr = col.GetAttribute<DisplayAttribute>(); return (attr != null ? attr.GetOrder() : null) ?? 0; }); }
— Reply to this email directly or view it on GitHubhttps://github.com/erichexter/twitter.bootstrap.mvc/issues/72.
@erroric - this is a good idea. You're implementation looks about right. It would help greatly if you could send a pull request with your updates, like you did for #46.
There is a Contributing wiki page with some tips on developing and testing changes to this package.
Hope that helps,
Hi. ViewHelperExtensions.cs -> VisibleProperties() extension ignores DisplayAttribute "Order" property in models.
I have suggest simple solution for this: