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
545
Change Hierarchy Descriptor on runtime
posted

It is possible to set new Level Descriptors on Runtime? The code below do not work. I dont know the reason why the pivot grid do not refresh the hierarchy

        private void ChangePeriodType(BusinessObjects.Constant.BudgetPeriodType type)
        {
            if (this.MyDateLevels != null && this.MyDateLevels.Count == 4 && this.MyDateDescriptor !=null)
            {
                this.FlatData.HierarchyDescriptors.Remove(this.MyDateDescriptor);
                switch (type)
                {
                    case Constant.BudgetPeriodType.Quarterly:
                        this.MyDateDescriptor.LevelDescriptors.Clear();
                        this.MyDateDescriptor.LevelDescriptors.AddRange(this.MyDateLevels.Take(3));
                        break;
                    case Constant.BudgetPeriodType.Yearly:
                        this.MyDateDescriptor.LevelDescriptors.Clear();
                        this.MyDateDescriptor.LevelDescriptors.AddRange(this.MyDateLevels.Take(2));
                        break;
                    default:
                        this.MyDateDescriptor.LevelDescriptors.Clear();
                        this.MyDateDescriptor.LevelDescriptors.AddRange(this.MyDateLevels);
                        break;
                }
                this.FlatData.AddHierarchyDescriptor(this.MyDateDescriptor);
                this.FlatData.RefreshGrid();
            }
        }
            Hierarchy = new HierarchyDescriptor<BudgetMainViewModel>(p => p.Date);
            Hierarchy.AppliesToPropertiesOfType = typeof(DateTime?);
            Hierarchy.AddLevel<DateTime?>(p => "Date", "Date");
            Hierarchy.AddLevel<DateTime?>(p => p.GetValueOrDefault().Year, "Year");
            Hierarchy.AddLevel<DateTime?>(p => p.GetValueOrDefault().QuarterShort(), "Quarter");
            Hierarchy.AddLevel<DateTime?>(p => p.GetValueOrDefault().MonthShort(), "Month");
            Expression<Func<DateTime?, int>> expression = (p => p.GetValueOrDefault().Month);
            Hierarchy.LevelDescriptors[3].OrderByKeyExpression = expression;
            Hierarchy.HierarchyDisplayName = "Date";
            this.MyDateDescriptor = Hierarchy;
            this.MyDateLevels = new List<HierarchyLevelDescriptor>(Hierarchy.LevelDescriptors);
            this.FlatData.AddHierarchyDescriptor(Hierarchy);
Parents
No Data
Reply
  • 138253
    Offline posted

    Hello Roman,

     

    I am just checking if you need any further assistance on the matter.

Children