Hello
I have a couple of questions regarding XamPivotGrid and FlatDataSource.
1.
I have a HierarchyDescriptor with a month:
dateTimeDataDescriptor.AddLevel<DateTime>(date => date.ToString("MMM", CultureInfo.CurrentCulture), "Months" );
It will give me the months like: jan, feb, mar, etc. The problem is when I sort, which will be sorted alphabetically. This is not correct in this case as you would expect jan to be first. Is there any way to control this?
2.
How do I set the default sorting to ASC. Whenever I add a row or a column I would like it to be sorted.
Hello,The OrderByKeyExpression property should be set to an expression in order to sort a hierarchy descriptor.
Expression<Func> orderByExpression = d => d.Date.Month; datesHierarchy.LevelDescriptors[0].OrderByKeyExpression = orderByExpression;
You can add LevelSortDirections to the FlatDataSource. LevelDefaultSortDirections list in order to sort the FlatDataSorce in code.
LevelSortDirection sortDirection = new LevelSortDirection();sortDirection.LevelUniqueName = "[DimensionName].[HierarchyName].[ LevelName]";sortDirection.SortDirection = ListSortDirection.Ascending;dataSource.LevelDefaultSortDirections.Add(sortDirection);
Both solutions works fine.
But regarding the sorting, the PivotGrid is pretty dynamic in my case. The user will add rows and columns from different sources. This means my [DimensionName] is very much dynamic and I dont know it.
The behaviour I am looking for is that all rows/colums is sorted acs by default. If the user change the sorting this should not be overwrited when calling LoadCustomazations() or RefresgGrid().
Do you have any suggestion on which event I could apply the sorting?
Hope my explanation makes sence :)
Hello,
The ResultChanged event fires when a slice is changed and could be used to apply a sorting logic after an update. You can review the Events for IOlapViewModel section at http://www.infragistics.com/help/wpf/xampivotgrid-handlingevents for additional details.
If you have other questions, do not hesitate to ask.