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
260
xamPivotGrid DataFormat
posted

I am trying to use the xamPivotGrid for the first time, with a FlatDataSource based on a DataTable as described in another post (http://blogs.infragistics.com/forums/t/65463.aspx).  One thing I cannot seem to get to work is the DisplayFormat for numeric columns.  Here is the code excerpt that isn't working correctly:

 

 

            var flatDataSource = new FlatDataSource()

            {

                ItemsSource = DataTableToList(dt),

                Cube = DataSourceBase.GenerateInitialCube(dt.TableName),

                DimensionsGenerationMode = DimensionsGenerationMode.Mixed

            };

          flatDataSource.Rows = DataSourceBase.GenerateInitialItems(groupByStr);

          flatDataSource.Measures = DataSourceBase.GenerateInitialItems(measuresStr);

          CubeMetadata cubeMetadata = new CubeMetadata();

           flatDataSource.CubesSettings.Add(cubeMetadata);

 

            foreach (DataColumn col in dt.Columns)

            {

                HierarchyDescriptor hier = new HierarchyDescriptor

                {

                    SourcePropertyName = col.ColumnName,

                };

                HierarchyLevelDescriptor entriesLevel = new HierarchyLevelDescriptor

                {

                    LevelName = col.ColumnName,

                    LevelExpressionPath = col.ColumnName

                };

                hier.LevelDescriptors.Add(entriesLevel);

                flatDataSource.HierarchyDescriptors.Add(hier);

 

                if (col.DataType == typeof(double))

                {

                    DimensionMetadata dm = new DimensionMetadata()

                    {

                        SourcePropertyName = col.ColumnName,

                        DisplayName = col.ColumnName,

                        DimensionType = DimensionType.Measure,

                        AggregatorType =  AggregatorType.Sum,

                        DisplayFormat = "{0:C2}"

                    };

                    cubeMetadata.DimensionSettings.Add(dm);

                }

            }

            return flatDataSource;

 

 

Parents
No Data
Reply Children