javascriptsproutcoresproutcore-views

SproutCore nested ListView's (SC.ListView)


I'm trying to present a list of contacts by department in a SproutCore app and attempted to nest a SC.ListView within another SC.ListView to no avail.

It's possible I could use SC.GridView to assist, however, the nested 'list' needs to be within the context of the first list. If this could be implemented similar to JQueryUI's accordion widget, that'd be even better!

Any suggestions would be appreciated!

Thanks, M.


Solution

  • Whatever you do, DO NOT nest a list in the items of another list. Performance would be noticeably awful.

    There are a bunch of options

    1) Write your own custom view. If you want fancy animations, this is the easiest option.

    2) Use a TreeController with a ListView, and the list will allow the appropriate items to open up, to show children. You declare your tree controller like

    App.listController = SC.TreeController.create({
      treeItemIsExpandedKey: "expanded", // the key that 'opens' the item
      treeItemChildrenKey: 'your-children' // the key on an item that contains an array of child items
    });