开发者

Build hierarchical lists of objects using MVC

I want to build an application in which the user store data in a hierarchical way, for example using nested lists of entries. for example

•entry1

•entry2

 °subentry1

 °subentry2

    -subsubentry1

•entry3

I was wondering which would be the best way to build this using an MVC pattern

I suppose that every list should be a controller array and every entry is a model object. but a list also has 开发者_StackOverflow中文版a title!

My guess is that the List controller array object should have two property: a title that is an Entry model object and a simple array in which you can store more List and Entry objects.

Sounds right?

the second point is, how do i connect the view objects? the Entry view and the List view objects should listen mouse and keyboard events. should they be connected using an id system?

Thanks

PS: btw i using sproutcore javascript framework to build my app. But i would like to leave the discussion as agnostic and open is possible.


I don't see why MVC has any impact on this question. All you are talking about is modelling the data. Your implementation fo how you actually display it can come up after you have determined how you will store it, but don't worry yourself with MVC at this stage.

Anyway, a quick answer and will leave you to research in greater depth which solution fits your use case best.

  • Adjacency List
  • Nested Set Model
  • Enumerated/Maeterialised Path
  • .. and the other one which I can't for the life of me remember.

I'm all for favoring Nested Set for modeling heirarchical data like you just mentioned, but I tend to also run Adjanceyc List alongside it, cause I find it easier to then interrogate my data structures.

Unless I totally misunderstoof your question, I don't understand why MVC is involved in this.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜