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
505
Sorting & EntityCollection
posted


I have 5 levels of entity objects to display in a xamdatatree, and I need them to display in a sorted order. I can't make an entityCollection sort without throwing errors, so I maked those lists with  [Display(AutoGenerateField = false)]  and added a property that returns a list of the lower level entites in the sorted order.


//simplifed example

public partial class EntityA : IComparable<EntityA>
{


        [Include]
        [Display(AutoGenerateField = false)]
        public EntityCollection<EntityB> SubItems { get; set; }


        public List<EntityB> SortedBList
        {
            get
            {
                List<EntityB> list = new List<EntityB>(SubItems);
                list.Sort();
                return list;
            }
        }

        public string Name { get; set; }


        public int CompareTo(EntityA other)
        {
            return Name.CompareTo(other.Name);
        }
}

            <ig:XamDataTree  ItemsSource="{Binding SortedAList}">
                <ig:XamDataTree.GlobalNodeLayouts>
                    <ig:NodeLayout Key="ALayout" TargetTypeName="EntityA" DisplayMemberPath="Name" />
                    <ig:NodeLayout Key="BLayout" TargetTypeName="EntityB" DisplayMemberPath="Name" />
                    <ig:NodeLayout Key="CLayout" TargetTypeName="EntityC" DisplayMemberPath="Name" />
                    <ig:NodeLayout Key="DLayout" TargetTypeName="EntityD" DisplayMemberPath="Name" />
                    <ig:NodeLayout Key="ELayout" TargetTypeName="EntityE" DisplayMemberPath="Name" />

                </ig:XamDataTree.GlobalNodeLayouts>
            </ig:XamDataTree>

 


Though all the objects are all set up this way, only the list under the root entity is using the sorted list property to display, the others use the entitycollection, dispite the  [Display(AutoGenerateField = false)]  tag (Not sure if this control actually takes that tag into account or not) 

Is there any way to make the control use one list over the other? Or is there any way to sort the itmes in the control?