views:

150

answers:

1

I have the following classes in my Model:

public abstract class Entity : IEntity
{
    [ScaffoldColumn(false)]
    public int Id { get; set; }
    [Required,StringLength(500)]
    public string Name { get; set; }
}

and

public class Model : SortableEntity
{
    [Required]
    public ModelType Type { get; set; }
    [ListRequired]
    public List<Producer> Producers { get; set; }
    public List<PrintArea> PrintAreas { get; set; }
    public List<Color> Colors { get; set; }
}

To display the "Model" class in the view I simply call Html.EditorFor(model=>model), but the "Name" property of the base class is rendered last, which is not the desired behaviour.

Is it possible to influenece on the order of displayed fields somehow?

A: 

I've not been able to find an attribute for that, so your options are:

1) create one, and then revise the base Object.ascx template to account for it, or 2) create a custom editor template for your classes that explicitly put stuff in the order you want.

Paul
Sounds reasonable. Ended up discarding base classes (Entity, SortableEntity etc.), creating interfaces (IEntity, ISortableEntity) and added correspoding properties manually in all the classes.
Anrie