I’m using Extensions for ASP.NET MVC Q3 2011(open source version) with Razor engine and Asp.net MVC3 architecture.
I want to bind a grid to a entity in my database which has self referring structure (like a tree). Therefore, I can not define it like examples with fixed levels, because I do not know how many levels this grid has. So, I want to bind my grid dynamically to a model.
public class Category : Entity
{
public virtual int Id {private set; get; }
public virtual string Title { set; get; }
public virtual string Description { set; get; }
public virtual string ParentsPath { set; get; }
public virtual IList<Category> Children { get; private set; }
public virtual Category Parent { get; set; }
}
I’m also using Fluent NHibernate and because of that I store children and parent in my entity.
Is there a way to do this? I couldn’t find anything in documentations.
Am I missing something? because in Ajax and Winform components, it has been implemented.
Thanks.
You cannot do it automatically, You need a foreach iteration and generating the items and then add them to the tree manually.
I did it for PanelBar when I needed to show a hierarchicy.
Here is an example :
)
Hope to be helpful.