Giter Site home page Giter Site logo

Comments (2)

erichexter avatar erichexter commented on July 19, 2024

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, Локтионов Алексей <[email protected]

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//issues/72.

from twitter.bootstrap.mvc.

serra avatar serra commented on July 19, 2024

@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,

from twitter.bootstrap.mvc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.