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()
DisplayName = col.ColumnName,
DimensionType = DimensionType.Measure,
AggregatorType = AggregatorType.Sum,
DisplayFormat = "{0:C2}"
cubeMetadata.DimensionSettings.Add(dm);
}
return flatDataSource;
figured it out - it was a simple matter of setting the correct DataTypeFullName on the CubeMetaData
Hi,
Glad you were able to find the solution. I created a sample with your code and we both came to the same conclusion.
I was just about to give you my sample with the DisplayTypeFullName and DisplayName added.