Hello,
I'm using a FlatDatasource and struggling to get control of how the Dimensions display in the DataSelector -- I want them to display a nice-looking string instead of the raw property names, but I can't get it to work. The data is coming from a DataTable which I've converted into a list of "dynamic objects". I'm building the Dimensions and Hierarchies based on the columns found in the original table.
Here's a watered down version of what I've tried (which seems to be exactly what's in the documentation).
flatDataSource.DimensionsGenerationMode = DimensionsGenerationMode.Mixed;
CubeMetaData cubeMetadata = new CubeMetadata();
foreach (DataColumn col in myTable.Columns) { // This seems to have no effect: DimensionMetaData dm = new DimensionMetadata() { SourcePropertyName = col.ColumnName, DisplayName = col.Caption, }; cubeMetadata.DimensionSettings.Add(dm); //heirarchy HierarchyDescriptor hier = new HierarchyDescriptor { SourcePropertyName = col.ColumnName, HierarchyName = col.Caption, HierarchyDisplayName = col.Caption };
HierarchyLevelDescriptor allLevel = new HierarchyLevelDescriptor { LevelName = "All " + col.Caption + "s" }; hier.LevelDescriptors.Add(allLevel);
HierararchyLevelDescriptor entriesLevel = new HierarchyLevelDescriptor { LevelName = col.Caption, LevelExpressionPath = col.Caption }; hier.LevelDescriptors.Add(entriesLevel);
flatDataSource.HierarchyDescriptors.Add(hier); } flatDataSource.CubesSettings.Add(cubeMetadata);I want the Dimension to display using the "Caption" property, not the "ColumnName" property from the column.I'm doing this by setting the DisplayName in the DimensionMetadata, but it seems to be ignored. Am I doing something wrong?
Thanks,Bob
Hello Bob,
I have been looking into your issue and you need to set the desired string value in the ‘DisplayName’ property of the DimensionMetadata like e.g. :
CubeMetadata cubeMetadata = new CubeMetadata();
cubeMetadata.DisplayName = "Sales Data";
cubeMetadata.DataTypeFullName = "IGPivotGrid.Samples.Controls.Sale";
cubeMetadata.DimensionSettings.Add(new DimensionMetadata()
{
SourcePropertyName = "City",
DisplayName = "City",
DimensionType = DimensionType.Measure,
Aggregator = new Infragistics.Olap.TopCountOfStringAggregator()
});
SourcePropertyName = "AmountOfSale",
DisplayName = "Amount Of Sale",
DisplayFormat = "{0:C2}",
Aggregator = new DoubleSumAggregator()
I am not exactly sure what happens in your application. Could you please check whether col.Caption return the desired string value ?
I am attaching a sample application(PivotGridFlatDataDimensionMetaData.zip) that shows my suggestion.
Hello Yanko,
First off, sorry for mangling the look of the initial post. I know it was hard to read... :-|
Anyway, my code was adapted directly from the example you sent. I am setting the DisplayName property of the DimensionMetadata. I can guarantee that col.Caption contains the value I want (note that I use it to define the Hierarchy display info, and that works perfectly). I have also tried setting the display format using DimensionMetadata, and that has had no effect either. It appears that the metadata is being ignored completely even though I have the DimensionGenerationMode set to Mixed on the FlatDataSource.
Is there another step I'm missing?
Bob