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
Yes, that was it, and it has to be set correctly to the type name of the objects in the ItemsSource (in my case "table.TableName", assigned while creating the dynamic types).
PLEEEEEEEEEEEEEEEEEEEEEEAAAAAAAAAAASSSSSSSSSSSSSSSSEEEEEEEEEEEE DOCUMENT THIS STUFF!!!!!!!!!!!!!!!!!!!!!!!! "Gets or sets the System.Type.FullName of data source items used as FlatDataSource.ItemsSource" does not tell us much, especially if having it set correctly is CRITICAL to getting the functionality to work. This has cost me over 2 weeks of time...
Bob
ps: This documentation issue is pervasive throughout the Infragistics toolset. C'mon people, these are complex components, and when the complete documentation of a property is "gets or sets the value of the xxx property", with absolutely no hint of what it means or what it does or why we would want to set it, how on earth are we supposed to be able to figure out how to use it?
The only thing I can see you're missing, at least in the code you've sent, is to set CubeMatada.DataTypeFullName.
Regards,Plamen.
Hi Bob,
Thank you for your feedback. I have been looking into this and seems that and other customers has converted a data table in flat data source and everything goes right :
http://es.infragistics.com/community/forums/t/65463.aspx
Could you please modify my sample application or attach your own one that demonstrates the issue that you have in order to test it on my side ?
Looking forward to hearing from you.
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?
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.