Menu

Adding sub items dynamically

2010-04-20
2012-10-30
  • ojuang karanja

    ojuang karanja - 2010-04-20

    Hello. Firstly thanks a bunch for this control its preety amazing. I'm having
    a little trouble understanding how to use the tree list view. So far i have
    successfully managed to create root nodes using the treelistview.roots method,
    now i'd like to add sub items to each root node. Now i've installed a
    childrengetter delegate, my issue is that the model that will be used to
    populate each child node is vastly different from the model used for the root
    nodes. Each root node is simply a 1 dimensional array list. the subnodes have
    different models, some being between 5 to 12 dimensional models(all being
    generated from various datatable). So far i keep getting an error 'cannot cast
    NodexModel as Rootmodel' How can i use the treelistview control to build a
    tree using a number of very different models? Sample code(even psudo code) is
    much appreciated

     
  • Phillip Piper

    Phillip Piper - 2010-04-26

    You could make all your model classes implement the same interface, for
    example, IChildrenProvider interface, and then simply call that within your
    ChildrenGetter delegate. That way, each model could decide how to provide
    children.

    public interface IChildrenProvider
        {
            IEnumerable GetChildren();
        }
    
     

Log in to post a comment.

MongoDB Logo MongoDB