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
5124
Loading Excel data with separate Month and Year Columns into XamPivotGrid
posted
I recently assisted a XamPivotGrid customer who was trying to load Excel data containing separate Month and Year columns (e.g., '01', '2011').  I discovered that this functionality is not possible with the current version (10.3) but will be available with the next release (11.1).

The current XamPivotGrid help documentation for loading Excel Data is located here: http://help.infragistics.com/NetAdvantage/DV/2010.3/CLR4.0/?page=xamPivotGrid_US_Excel_Spreadsheet_As_A_DataSource.html

The following code (taken from the help doc above) does NOT work for the Month/Year column use case:


flatDataSource.Columns = DataSourceBase.GenerateInitialItems("[Date]");


.


.


.


HierarchyDescriptor dateTimeDescriptor =


            new HierarchyDescriptor


            {


                AppliesToPropertiesOfType = typeof(DateTime)


            };


            dateTimeDescriptor.AddLevel(date => "All Dates", "All Values");


            dateTimeDescriptor.AddLevel(date => date.Year, "Years");


            dateTimeDescriptor.AddLevel(date => date.Date, "Members");


                                      

Below is a code snippet provided by our engineers to work with the 11.1 version of the XamPivot Grid.  I expect our 11.1 version of the documentation to have this code, or something similar.  However, for those awaiting this functionality in 11.1, this is for your reference.
Parents
No Data
Reply
  • 5124
    posted
    HierarchyLevelDescriptor allLevel = new HierarchyLevelDescriptor
                {
                    LevelName = "All"
                };

                
                HierarchyLevelDescriptor yearLevel =
                    new HierarchyLevelDescriptor
                    {
                        LevelName = "Years",
                        LevelExpressionPath = "Year"
                    };

                
                HierarchyLevelDescriptor monthLevel =
                    new HierarchyLevelDescriptor
                    {
                        LevelName = "Month",
                        LevelExpressionPath = "Month"
                    };

                dateTimeDescriptor.LevelDescriptors.Add(allLevel);
                dateTimeDescriptor.LevelDescriptors.Add(yearLevel);
                dateTimeDescriptor.LevelDescriptors.Add(monthLevel);
Children
No Data