Hello,
I have a issue with header order, can I order a DateTime field?
I'm using 14.1, but I tested in 15.1 and did not fix it.
Code:
dimMetadata = new DimensionMetadata(); dimMetadata.SourcePropertyName = "DT_FIELD"; dimMetadata.DisplayName = "Date"; dimMetadata.AggregatorType = AggregatorType.None; dimMetadata.AutoGenerateField = false; dimMetadata.DimensionType = DimensionType.Dimension; cubeMetadata.DimensionSettings.Add(dimMetadata);
outputFlatDataSource.CubesSettings.Add(cubeMetadata);
Thanks,
Fernando
Hello nandoviski,
Thank you for your post.
The code that you have provided will not reorder the DateTime field in the XamPivotGrid. What you need here is a sorting operation. You can apply a sort to a FlatDataSource by following the instructions presented here: http://help.infragistics.com/doc/WPF/2014.2/CLR4.0/?page=xamPivotGrid_Sorting_Rows_and_Columns.html.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
Hello Andrew,
Thanks for your reply.
Can I a sorting operation if I am using dynamic class?? Because I don't know what kind of object it will populate.
For example, you are using "Expression<Func<Sale, String>>" in the sample, but I don't have the class "Sale", for me, this class is dynamic (I'm using 'DynamicTypeBuilder').
Can I do that?
Thank you.
Since you are using a dynamic type, I would recommend that you modify your Expression to be an Expression<Func<object, "out type">>, and handle the return value in an external method. For example, you could use something along the lines of this:
Expression<Func<object, int>> expression = (e) => MyOutsideMethod(e).
Your external method would return an int value, and take an object as a parameter. Then, you can use reflection to get the value of your object, e.
I have attached a sample application to demonstrate the above.
Thank you for reply. Your sample works perfectly.
But when I sorted the date I lost the grouping by year, month, semester, etc. Can I sort and use group at the same time?
Thanks
In the sample I had sent you, you may notice that the section where the HierarchyLevelDescriptors are added include two descriptors. The first one is named "All Periods" and is the top level that you see in the XamPivotGrid when adding the "Date123" measure. After expanding that, you will see the second level. The HierarchyLevelDescriptor for that level has the "LevelExpressionPath" property set to "Date123." This is why you are seeing the full date on that level. If you were to map it to "Date123.Year" you would see the year in the grid.
So to answer your question, yes, you can sort and use grouping on your date field concurrently. You would just need to add a HierarchyLevelDescriptor that has its LevelExpressionPath set to "Date123.(Year, Month, Day, Semester, etc)." Then, apply the sort much like the sort was applied to the "Date123" mapped level.
I hope this helps you. Please let me know if you have any other questions or concerns on this matter.
Thank you Andrew, it works perfectly...
Edit:
I just changed the property "PreserveMembersOrder" to false and It works too.
outputFlatDataSource.PreserveMembersOrder = false;