Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
160
Ultragrid Hierarchical DataSource with Multiple Level Paths
posted

I have a class

 

    public class MyObject {

        public string Caption { get; set; }

        public string SomeText { get; set; }

        public IList<MyObject> ChildItems { get; set; }

        public Dictionary<string,Action> ItemActions { get; set; }

    }

 

and an UltraGrid whose DataSource will be an IList<MyObject>.

 

    IList<MyObject> list = ListRepository.GetAll<MyObject>();

    MyUltraGrid.DataSource = list.

 

When I set an IList<MyObject> as the UltraGrid's DataSource it seems that the Dictionary property ItemActions is being chosen as the property to use to create bands in the grid and I get Key Not Found exceptions when trying to access columns in lower bands, because I'm expecting the columns in lower bands to be keyed of of other properties of MyObject.

For example:

    MyGrid.DisplayLayout.Bands[1].Columns["SomeText"].PerformAutoResize();

would result in an exception because the "SomeText" key of the Columns collection doesn't exist.  Band[1] gets created from the Dictionary property of MyObject instead of the IList<MyObject> property.

I have worked around this for now by changing the ItemActions property to type Object instead of a Dictionary and casting when I need to reference it, but I'd rather not have to do that.

Is there a way to force the UltraGrid binding to choose ChildItems as the hierarchy path?

Parents Reply Children