Please see FlatDataExample.xaml.cs in the attached project.
Note this section:
// Crashes here if hierarchies and levels have the same name. // However, changing names causes hierarchies not to display in pivot grid.
PeopleGrid.DataSource.Filters.Add(PeopleGrid.DataSource.CreateFilterViewModel( PeopleGrid.DataSource.Cube.Dimensions["Gender"].Hierarchies.First()));
PeopleGrid.DataSource.Filters.Add(PeopleGrid.DataSource.CreateFilterViewModel( PeopleGrid.DataSource.Cube.Dimensions["TypeCode"].Hierarchies.First())); I've tried changing the hierarchy and level names however when I do that the pivot grid does not display any dimenions.The code below is a WORKING page from a different project that is running the same version of Infragistics (I checked each dll).Why does it work?
<igFlatData:FlatDataSource x:Key="RollBookDataSource" x:Shared="False" Rows="[PIMCO_DESC].[Product],[BROKER].[Broker]" Columns="[Measure].[Measure]" Measures="Long,Short,Net"> <igFlatData:FlatDataSource.ConnectionSettings> <igFlatData:FlatDataConnectionSettings ItemsSource="{Binding}"/> </igFlatData:FlatDataSource.ConnectionSettings> <igFlatData:FlatDataSource.CubesSettings> <igFlatData:CubeMetadata DataTypeFullName="Poolman.Models.TBARollPivotItem"> <igFlatData:DimensionMetadata SourcePropertyName="Long" DisplayFormat="{}{0:#,#;(#,#)}"/> <igFlatData:DimensionMetadata SourcePropertyName="Short" DisplayFormat="{}{0:#,#;(#,#)}"/> <igFlatData:DimensionMetadata SourcePropertyName="Net" DisplayFormat="{}{0:#,#;(#,#)}"/> </igFlatData:CubeMetadata> </igFlatData:FlatDataSource.CubesSettings> <igFlatData:FlatDataSource.HierarchyDescriptors> <igFlatData:HierarchyDescriptor SourcePropertyName="{x:Static local:TBARollBook.kMeasure}"> <igFlatData:HierarchyDescriptor.LevelDescriptors> <igFlatData:HierarchyLevelDescriptor LevelName="Type" LevelExpressionPath="Measure.Type"/> </igFlatData:HierarchyDescriptor.LevelDescriptors> </igFlatData:HierarchyDescriptor> <igFlatData:HierarchyDescriptor SourcePropertyName="PM_NAME" HierarchyName="{x:Static local:TBARollBook.kFilterPM}"> <igFlatData:HierarchyDescriptor.LevelDescriptors> <igFlatData:HierarchyLevelDescriptor LevelName="All"/> <igFlatData:HierarchyLevelDescriptor LevelName="PM" LevelExpressionPath="PM_NAME"/> </igFlatData:HierarchyDescriptor.LevelDescriptors> </igFlatData:HierarchyDescriptor> <igFlatData:HierarchyDescriptor SourcePropertyName="DELIVERY_DT" HierarchyName="{x:Static local:TBARollBook.kFilterDelivery}"> <igFlatData:HierarchyDescriptor.LevelDescriptors> <igFlatData:HierarchyLevelDescriptor LevelName="All"/> <igFlatData:HierarchyLevelDescriptor LevelName="Delivery" LevelExpressionPath="DELIVERY_DT"/> </igFlatData:HierarchyDescriptor.LevelDescriptors> </igFlatData:HierarchyDescriptor> <igFlatData:HierarchyDescriptor SourcePropertyName="ROLL_IND" HierarchyName="{x:Static local:TBARollBook.kFilterRoll}"> <igFlatData:HierarchyDescriptor.LevelDescriptors> <igFlatData:HierarchyLevelDescriptor LevelName="Roll" LevelExpressionPath="ROLL_IND"/> </igFlatData:HierarchyDescriptor.LevelDescriptors> </igFlatData:HierarchyDescriptor> <igFlatData:HierarchyDescriptor SourcePropertyName="TURN_IND" HierarchyName="{x:Static local:TBARollBook.kFilterTurn}"> <igFlatData:HierarchyDescriptor.LevelDescriptors> <igFlatData:HierarchyLevelDescriptor LevelName="Turn" LevelExpressionPath="TURN_IND"/> </igFlatData:HierarchyDescriptor.LevelDescriptors> </igFlatData:HierarchyDescriptor> <igFlatData:HierarchyDescriptor SourcePropertyName="PIMCO_DESC" HierarchyName="{x:Static local:TBARollBook.kViewProduct}"> <igFlatData:HierarchyDescriptor.LevelDescriptors> <igFlatData:HierarchyLevelDescriptor LevelName="All"/> <igFlatData:HierarchyLevelDescriptor LevelName="Product" LevelExpressionPath="PIMCO_DESC"/> </igFlatData:HierarchyDescriptor.LevelDescriptors> </igFlatData:HierarchyDescriptor> <igFlatData:HierarchyDescriptor SourcePropertyName="BROKER" HierarchyName="{x:Static local:TBARollBook.kViewBroker}"> <igFlatData:HierarchyDescriptor.LevelDescriptors> <igFlatData:HierarchyLevelDescriptor LevelName="All"/> <igFlatData:HierarchyLevelDescriptor LevelName="Broker" LevelExpressionPath="BROKER"/> </igFlatData:HierarchyDescriptor.LevelDescriptors> </igFlatData:HierarchyDescriptor> </igFlatData:FlatDataSource.HierarchyDescriptors> </igFlatData:FlatDataSource> RollGrid.DataSource.Filters.Add(RollGrid.DataSource.CreateFilterViewModel( RollGrid.DataSource.Cube.Dimensions["PM_NAME"].Hierarchies.First())); FilterPM();
RollGrid.DataSource.Filters.Add(RollGrid.DataSource.CreateFilterViewModel( RollGrid.DataSource.Cube.Dimensions["DELIVERY_DT"].Hierarchies.First())); FilterDelivery();
RollGrid.DataSource.Filters.Add(RollGrid.DataSource.CreateFilterViewModel( RollGrid.DataSource.Cube.Dimensions["TURN_IND"].Hierarchies.First())); FilterTurn();
RollGrid.DataSource.Filters.Add(RollGrid.DataSource.CreateFilterViewModel( RollGrid.DataSource.Cube.Dimensions["ROLL_IND"].Hierarchies.First())); FilterRoll();
Hi Sam,
Should I expect this sample to crash? If no, what I need to change in order to reproduce the crash?Using build 11.2.20112.2125 it works fine.
Plamen.
Yes, this code does crash. Wrap the code I highlighted earlier in a try block and put a breakpoint in it. You will see the exception below. Note that for some reason the exception is silent. It crashes on the first line shown below then execution returns to App.xaml.cs. However if you wrap it in a try block (or place a breakpoint on it ) you will catch the exception.
As I said there is a page in the project I'm working on that has working code (see my original post). For my page, I am unable to find the right combination of hierarchy/level names to use for the "Rows" and "Columns" properties of the flatdatasource. I only see dimenions on the pivotgrid if levelname and hierarchyname are the same. Of course, when the names are the same the filters cannot be added.
The version of the controls I am using is 11.2.20112.2125
try { PeopleGrid.DataSource.Filters.Add(PeopleGrid.DataSource.CreateFilterViewModel( PeopleGrid.DataSource.Cube.Dimensions["Gender"].Hierarchies.First()));
PeopleGrid.DataSource.Filters.Add(PeopleGrid.DataSource.CreateFilterViewModel( PeopleGrid.DataSource.Cube.Dimensions["TypeCode"].Hierarchies.First())); } catch (Exception ex) { // look at ex here }
Here is the exeception. If you look at PeopleGrid.DataSource.Filters.Count in the watch window you will see that it is zero. So I dont know why this exception is thrown.
Item is already added to the collection! at Infragistics.Olap.AreaItemsCollection.OnCollectionChanging(NotifyCollectionChangedEventArgs e) at Infragistics.Olap.SwapCollection`1.InsertItemInternal(Int32 index, T item, Boolean suppressMessages) at Infragistics.Olap.SwapCollection`1.InsertItem(Int32 index, T item) at System.Collections.ObjectModel.Collection`1.Add(T item) at PivotGridTest.FlatDataExample.PeopleGrid_Loaded(Object sender, RoutedEventArgs e) in \\Visual Studio 2010\Projects\PivotGridTest2\PivotGridTest\FlatDataExample.xaml.cs:line 123
You're right, there is an exception. It occurs because you already have added those hierarchies from XAML. It's something I've missed to see before.
Setting those properties will cause initialization of the pivot grid with the specified hierchies. The code behind is trying to add a new filter view model for the same hierarchy again and that's where the exception occurs, because you're allowed to have that hierarchy just in Filters or just in Columns at a time.
Regards.Plamen.
Thank you Plamen, that makes sense. However, if I do not add the filters as I was attempting to do the ExpandDimensions method does not work. Can you tell me why? I copied ExpandDimensions from a working page.
BTW Thank you for your patience!!
Sam
Plamen I found it thanks to your example. I was not wiring up the herarchy changed event inside the ExpandDimensions method.
private void ExpandDimensions(){
PeopleGrid.DataSource.ResultChanged += FilterHelper.HierarchyChanged;
}
public void HierarchyChanged(object sender, AsyncCompletedEventArgs e) { DataSourceBase dataSourceBase = (DataSourceBase)sender; dataSourceBase.ResultChanged -= HierarchyChanged;
dataSourceBase.HierarchyExpansionMode = HierarchyExpansionMode.DrillDown; dataSourceBase.UpdateVisualMembers(Infragistics.Olap.ExecutionContext.Rows); dataSourceBase.UpdateVisualMembers(Infragistics.Olap.ExecutionContext.Columns); dataSourceBase.HierarchyExpansionMode = HierarchyExpansionMode.SingleLevelOnly;
dataSourceBase.RefreshGrid(); }
Hi Plamen, The following is code from a working page from our project. I will look at the changes you posted on the other thread.
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Navigation;using System.Windows.Shapes;using Infragistics.Olap.FlatData;using Infragistics.Olap;using Infragistics.Olap.Data;using System.Threading;using Poolman.Models;using Infragistics.Controls.Grids;using System.ComponentModel;using Poolman.Entities;using System.Collections.ObjectModel;using System.Linq.Expressions;using Poolman.Common;
namespace Poolman.Views{ public partial class TBARollBook : UserControl { public TBARollBookViewModel ViewModel { get { return (TBARollBookViewModel)DataContext; } }
private ManualResetEvent _mre; private bool RollBookLoaded;
/* we are using the built in filter/hierarchy * * mechanisms of the XamPivotGrid which require * * using some magic strings which correspond to * * properties shown in the control */ public static string kViewProduct = "Product"; public static string kViewBroker = "Broker"; public static string kViewAccount = "Account"; public static string kBookLast = "As of Last Close"; public static string kBookLive = "Live"; public static string kBookMust = "Must Roll"; public static string kFilterRoll = "Roll"; public static string kFilterDelivery = "Delivery"; public static string kFilterPM = "PM"; public static string kFilterTurn = "Turn"; public static string kFilterFail = "Fail"; public static string kMeasure = "Measure";
public TBARollBook() { InitializeComponent(); RollBookLoaded = false; this.DataContext = new TBARollBookViewModel(); Loaded += new RoutedEventHandler(TBARollBook_Loaded); Dispatcher.ShutdownStarted += (s, e) => OnSaveLayout(User.CurrentUser.APP_LAYOUT); }
void TBARollBook_Loaded(object sender, RoutedEventArgs e) { Loaded -= new RoutedEventHandler(TBARollBook_Loaded); OnRestoreLayout(User.CurrentUser.APP_LAYOUT); }
private void LoadRollBook() { RollGrid.DataSource = (IOlapViewModel)FindResource("RollBookDataSource"); ((FlatDataSource)RollGrid.DataSource).ItemsSource = ViewModel.RollBook; RollGrid.DataSource.ResultChanged += OnResultChanged;
// Bug in Infragistics version 11.1 - sort expressions do not work. - see the following thread. // http://community.infragistics.com/forums/p/65104/329867.aspx#329867
//System.Linq.Expressions.Expression<Func<TBARollPivotItem, string>> sortCusip = x => new Random().Next().ToString(); //System.Linq.Expressions.Expression<Func<TBARollPivotItem, string>> sortBroker = x => x.Position.BROKER; //source.HierarchyDescriptors[6].LevelDescriptors[1].OrderByKeyExpression = sortCusip; //source.HierarchyDescriptors[6].LevelDescriptors[2].OrderByKeyExpression = sortBroker; //source.HierarchyDescriptors[6].LevelDescriptors[1].OrderByKeyExpression = sortCusip; //source.HierarchyDescriptors[7].LevelDescriptors[1].OrderByKeyExpression = sortBroker;
RollGrid.DataSource.Filters.Add(RollGrid.DataSource.CreateFilterViewModel( RollGrid.DataSource.Cube.Dimensions["PM_NAME"].Hierarchies.First())); FilterPM();
/* populate combo boxes with distinct values from filter */ ViewModel.DeliveryDates = new List<string> { "All", "All Failing" }.Union( from p in ViewModel.RollBook orderby p.Position.DELIVERY_DT select p.DELIVERY_DT).Distinct().ToList();
/* set default book */ FilterBook();
/* set default view */ FilterView();
//ViewModel.PropertyChanged += ViewModelPropertyChanged;
RollBookLoaded = true; }
private void ViewModelPropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "RollBook") { Dispatcher.BeginInvoke(new Action(delegate() { LoadRollBook(); })); } }
private void OnResultChanged(object sender, AsyncCompletedEventArgs e) { FlatDataSource fds = (FlatDataSource)RollGrid.DataSource; List<TBARollPosition> ResultPositions = new List<TBARollPosition>();
List<int> indices = fds.GetCellItemsIndexes( fds.Result.Cells[fds.Result.Cells.GetUpperBound(0), fds.Result.Cells.GetUpperBound(1)]); foreach (int index in indices) { ResultPositions.Add(((TBARollPivotItem)fds.GetRecord(index)).Position); }
ViewModel.ResultPositions = new ObservableCollection<TBARollPosition>(ResultPositions); }
private void OnLoaded(object sender, RoutedEventArgs e) { if (!RollBookLoaded) { LoadRollBook();
/* hide some filters of the XamPivotGrid which are set in code */ RollGrid.MeasuresDropControl.Visibility = Visibility.Collapsed; RollGrid.ColumnsDropControl.Visibility = Visibility.Collapsed; RollGrid.FiltersDropControl.Visibility = Visibility.Collapsed;
/* default filter Options = All */ ViewModel.SelectedPMs = "All"; ViewModel.SelectedDelivery = "All";
/* for convenience set Delivery Date to nearest pool day */ ViewModel.SelectedDelivery = String.Format("{0:MM/dd/yyyy}", ViewModel.DeliveryDates .Where(x => !x.Contains("All") && Convert.ToDateTime(x) > DateTime.Now.Date && Common.Utilities.GetBusinessDays(DateTime.Now, Convert.ToDateTime(x)) > 2) .Min(x => Convert.ToDateTime(x))); } }
private IFilterViewModel GetFilterViewModel(FlatDataSource source, string caption) { foreach (var filter in source.Filters) { if (filter.Caption == caption) { return (IFilterViewModel)filter; } }
foreach (var row in source.Rows) { if (row.Caption == caption) { return (IFilterViewModel)row; } }
foreach (var column in source.Columns) { if (column.Caption == caption) { return (IFilterViewModel)column; } }
return null; }
private void ExpandHierarchy(IFilterMember filter, bool value) { _mre = new ManualResetEvent(false);
if (filter.IsExpanded != value) { filter.IsExpanded = value; }
if (filter.FilterMembers == null) { _mre.WaitOne(); }
foreach (var child in filter.FilterMembers) { ExpandHierarchy(child, value); } }
private void SetFilter(IFilterMember filter, string value, bool set) { _mre = new ManualResetEvent(false);
if (filter.Caption == value) { filter.IsSelected = set; } /* expand the filter if closed */ if (!filter.IsExpanded) { filter.IsExpanded = true; _mre.WaitOne(); }
foreach (var child in filter.FilterMembers) { SetFilter(child, value, set); } }
private void OnPMChanged(object sender, SelectionChangedEventArgs e) { //ViewModel.SelectedPMs = PMFilter.SelectedItems.Cast<PortfolioManager>().ToList(); FilterPM(); RollGrid.DataSource.RefreshGrid(); }
private void OnDeliveryChanged(object sender, SelectionChangedEventArgs e) { FilterDelivery(); RollGrid.DataSource.RefreshGrid(); }
private void FilterPM() { //if (ViewModel.SelectedPMs.Count > 0) //{ // FilterOption(kFilterPM, "All", false); // foreach (var pm in ViewModel.SelectedPMs) // { // FilterOption(kFilterPM, pm.Name); // } //} //else //{ // FilterOption(kFilterPM, "All"); //}
if (ViewModel.SelectedPMs != null) { FilterOption(kFilterPM, "All", false); foreach (var pm in ViewModel.SelectedPMs.Split('\\')) { FilterOption(kFilterPM, pm); } } }
private void FilterDelivery() { FilterOption(kFilterDelivery, "All", false); if (ViewModel.SelectedDelivery == "All Failing") { ViewModel.IsNetFails = false; NetFails.IsEnabled = false; foreach (var date in ViewModel.DeliveryDates) { if (!date.Contains("All") && Convert.ToDateTime(date) < DateTime.Today) { FilterOption(kFilterDelivery, date); } } } else { NetFails.IsEnabled = true; FilterOption(kFilterDelivery, ViewModel.SelectedDelivery); } }
private void FilterOption(string tag, string value, bool set=true) { IFilterViewModel fvm = GetFilterViewModel( (FlatDataSource)RollGrid.DataSource, tag);
fvm.LoadFilterMembersCompleted += (s, e) => _mre.Set();
if (fvm.FilterMembers != null) { foreach (var filter in fvm.FilterMembers) { SetFilter(filter, value, set); } }
fvm.CommitChanges(); }
private void OnBookChanged(object sender, RoutedEventArgs e) { FilterBook(); RollGrid.DataSource.RefreshGrid(); }
private void FilterBook() { IFilterViewModel fvm = GetFilterViewModel( (FlatDataSource)RollGrid.DataSource, kMeasure);
foreach (var filter in fvm.FilterMembers) { if (filter.Caption == kBookLast) { filter.IsSelected = ViewModel.IsLastRoll; }
if (filter.Caption == kBookLive) { filter.IsSelected = ViewModel.IsLiveRoll; }
if (filter.Caption == kBookMust) { filter.IsSelected = ViewModel.IsMustRoll; } }
private void OnViewChanged(object sender, RoutedEventArgs e) { FilterView(); }
private void FilterView() { RollGrid.DataSource.DeferredLayoutUpdate = true;
FlatDataSource source = (FlatDataSource)RollGrid.DataSource; IFilterViewModel product = GetFilterViewModel(source, kViewProduct); product.LoadFilterMembersCompleted += (s, e) => _mre.Set(); foreach (IFilterMember member in product.FilterMembers) { ExpandHierarchy(member, true); }
IFilterViewModel broker = GetFilterViewModel(source, kViewBroker); broker.LoadFilterMembersCompleted += (s, e) => _mre.Set(); foreach (IFilterMember member in broker.FilterMembers) { ExpandHierarchy(member, ViewModel.IsBrokerView); }
RollGrid.DataSource.ResultChanged += HierarchyChanged; RollGrid.DataSource.DeferredLayoutUpdate = false;
RollGrid.Visibility = ViewModel.IsAccountView ? Visibility.Collapsed : Visibility.Visible; AccountGrid.Visibility = ViewModel.IsAccountView ? Visibility.Visible : Visibility.Collapsed; }
private void HierarchyChanged(object sender, AsyncCompletedEventArgs e) { DataSourceBase dataSourceBase = (DataSourceBase)sender; dataSourceBase.ResultChanged -= HierarchyChanged;
private void OnRollChanged(object sender, RoutedEventArgs e) { FilterRoll(); RollGrid.DataSource.RefreshGrid(); }
private void FilterRoll() { IFilterViewModel fvm = GetFilterViewModel( (FlatDataSource)RollGrid.DataSource, kFilterRoll); foreach (var filter in fvm.FilterMembers) { if (filter.Caption == "N") { filter.IsSelected = ViewModel.IsRollAll; } }
private void OnTurnChanged(object sender, RoutedEventArgs e) { FilterTurn(); RollGrid.DataSource.RefreshGrid(); }
private void FilterTurn() { IFilterViewModel fvm = GetFilterViewModel( (FlatDataSource)RollGrid.DataSource, kFilterTurn);
foreach (var filter in fvm.FilterMembers) { if (filter.Caption == "Y") { filter.IsSelected = ViewModel.IsTurnYes; }
if (filter.Caption == "N") { filter.IsSelected = ViewModel.IsTurnNo; } }
private void OnFailsChanged(object sender, RoutedEventArgs e) { ViewModel.BuildRollBook(); LoadRollBook(); }
private void OnDrillDown(object sender, PivotCellClickedEventArgs e) { ViewModel.RollDrillDown.Clear();
ICell cell = (ICell)RollGrid.ActiveCell.Data; if (cell != null) { FlatDataSource fds = (FlatDataSource)RollGrid.DataSource; List<int> indices = fds.GetCellItemsIndexes(cell);
foreach (int index in indices) { TBARollPivotItem item = (TBARollPivotItem)fds.GetRecord(index); if (item.Net != 0) { ViewModel.RollDrillDown.Add(item); } } }
ViewModel.TBADrillDown = RollGrid.ActiveCell.DataRow.Tuple.Members[0].Name + " (" + RollGrid.ActiveCell.DataColumn.Tuple.Members[0].Name + ")";
TBARollDrillDown window = new TBARollDrillDown(ViewModel); window.Owner = Application.Current.MainWindow; window.WindowStartupLocation = WindowStartupLocation.CenterOwner; window.ShowDialog(); }
private void OnRefresh(object sender, RoutedEventArgs e) { ViewModel.Refresh(); LoadRollBook(); }
private void ExcelButton_Click(object sender, RoutedEventArgs e) { string filePath = "";
if (ViewModel.IsAccountView) { filePath = Common.Utilities.GetUniqueFileName(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "TBARollBookAccounts.xlsx")); Common.Utilities.ExportGridAsync(AccountGrid, filePath); } else { if(ViewModel.IsBrokerView) filePath = Common.Utilities.GetUniqueFileName(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "TBARollBookBrokers.xls")); else filePath = Common.Utilities.GetUniqueFileName(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "TBARollBookProducts.xls"));
Common.PivotGridExporter exporter = new Common.PivotGridExporter(); exporter.ExportToExcel(RollGrid, filePath, true, true); } }
public void OnSaveLayout(AppLayout layout) { layout.TBARollBookLayout = AccountGrid.SaveCustomizations(); }
public void OnRestoreLayout(AppLayout layout) { if (!string.IsNullOrWhiteSpace(layout.TBARollBookLayout)) AccountGrid.LoadCustomizations(layout.TBARollBookLayout); }
private void OnCellRightClicked(object sender, Behaviors.CellRightClickedEventArgs e) { // Cell will be null if it is a row or column header cell. PivotCell cell = null;
if (e.Cell != null) { cell = (PivotCell)e.Cell.Cell;
if(RollGrid.ActiveCell != null) RollGrid.ActiveCell.IsSelected = false; RollGrid.ActiveCell = cell; RollGrid.ActiveCell.IsSelected = true; } ViewModel.MouseOverCell = cell; } }}
<UserControl x:Class="Poolman.Views.TBARollBook" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:igPivot="http://schemas.infragistics.com/xaml" xmlns:igFlatData="http://schemas.infragistics.com/olap" xmlns:igDP="http://infragistics.com/DataPresenter" xmlns:igExt="clr-namespace:PIMCO.Infra.Extensions;assembly=PIMCO.Infragistics.Extensions" xmlns:local="clr-namespace:Poolman.Views" xmlns:ig="http://schemas.infragistics.com/xaml" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:Behaviors="clr-namespace:Poolman.Behaviors" xmlns:localControls="clr-namespace:Poolman.Controls"> <UserControl.Resources> <Style x:Key="ShortStyle" TargetType="{x:Type igPivot:PivotCellControl}" BasedOn="{StaticResource PivotCellStyle}"> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Cell.Data.Value, Converter={StaticResource IsNegative}}" Value="True"> <Setter Property="Foreground" Value="Red"/> </DataTrigger> </Style.Triggers> <Setter Property="HorizontalContentAlignment" Value="Right"/> <Setter Property="FontFamily" Value="Calibri"/> <Setter Property="FontSize" Value="13"/> </Style> <Style x:Key="TotalRowCellStyle" TargetType="{x:Type igPivot:PivotCellControl}" BasedOn="{StaticResource ShortStyle}"> <Setter Property="Background" Value="#444444"/> <Setter Property="FontFamily" Value="Calibri"/> <Setter Property="FontSize" Value="13"/> </Style> <Style x:Key="CellStyle" TargetType="igPivot:PivotCellControl" BasedOn="{StaticResource ShortStyle}"> <Setter Property="Background" Value="#222222"/> </Style> <Style x:Key="TotalCellStyle" TargetType="igPivot:PivotCellControl" BasedOn="{StaticResource TotalRowCellStyle}"> <Setter Property="Background"> <Setter.Value> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#B2D6D6D6" Offset="1"/> <GradientStop Color="#B2E7E7E7" Offset="0"/> </LinearGradientBrush> </Setter.Value> </Setter> </Style> <igFlatData:FlatDataSource x:Key="RollBookDataSource" x:Shared="False" Rows="[PIMCO_DESC].[Product],[BROKER].[Broker]" Columns="[Measure].[Measure]" Measures="Long,Short,Net"> <igFlatData:FlatDataSource.ConnectionSettings> <igFlatData:FlatDataConnectionSettings ItemsSource="{Binding}"/> </igFlatData:FlatDataSource.ConnectionSettings> <igFlatData:FlatDataSource.CubesSettings> <igFlatData:CubeMetadata DataTypeFullName="Poolman.Models.TBARollPivotItem"> <igFlatData:DimensionMetadata SourcePropertyName="Long" DisplayFormat="{}{0:#,#;(#,#)}"/> <igFlatData:DimensionMetadata SourcePropertyName="Short" DisplayFormat="{}{0:#,#;(#,#)}"/> <igFlatData:DimensionMetadata SourcePropertyName="Net" DisplayFormat="{}{0:#,#;(#,#)}"/> </igFlatData:CubeMetadata> </igFlatData:FlatDataSource.CubesSettings> <igFlatData:FlatDataSource.HierarchyDescriptors> <igFlatData:HierarchyDescriptor SourcePropertyName="{x:Static local:TBARollBook.kMeasure}"> <igFlatData:HierarchyDescriptor.LevelDescriptors> <igFlatData:HierarchyLevelDescriptor LevelName="Type" LevelExpressionPath="Measure.Type"/> </igFlatData:HierarchyDescriptor.LevelDescriptors> </igFlatData:HierarchyDescriptor> <igFlatData:HierarchyDescriptor SourcePropertyName="PM_NAME" HierarchyName="{x:Static local:TBARollBook.kFilterPM}"> <igFlatData:HierarchyDescriptor.LevelDescriptors> <igFlatData:HierarchyLevelDescriptor LevelName="All"/> <igFlatData:HierarchyLevelDescriptor LevelName="PM" LevelExpressionPath="PM_NAME"/> </igFlatData:HierarchyDescriptor.LevelDescriptors> </igFlatData:HierarchyDescriptor> <igFlatData:HierarchyDescriptor SourcePropertyName="DELIVERY_DT" HierarchyName="{x:Static local:TBARollBook.kFilterDelivery}"> <igFlatData:HierarchyDescriptor.LevelDescriptors> <igFlatData:HierarchyLevelDescriptor LevelName="All"/> <igFlatData:HierarchyLevelDescriptor LevelName="Delivery" LevelExpressionPath="DELIVERY_DT"/> </igFlatData:HierarchyDescriptor.LevelDescriptors> </igFlatData:HierarchyDescriptor> <igFlatData:HierarchyDescriptor SourcePropertyName="ROLL_IND" HierarchyName="{x:Static local:TBARollBook.kFilterRoll}"> <igFlatData:HierarchyDescriptor.LevelDescriptors> <igFlatData:HierarchyLevelDescriptor LevelName="Roll" LevelExpressionPath="ROLL_IND"/> </igFlatData:HierarchyDescriptor.LevelDescriptors> </igFlatData:HierarchyDescriptor> <igFlatData:HierarchyDescriptor SourcePropertyName="TURN_IND" HierarchyName="{x:Static local:TBARollBook.kFilterTurn}"> <igFlatData:HierarchyDescriptor.LevelDescriptors> <igFlatData:HierarchyLevelDescriptor LevelName="Turn" LevelExpressionPath="TURN_IND"/> </igFlatData:HierarchyDescriptor.LevelDescriptors> </igFlatData:HierarchyDescriptor> <igFlatData:HierarchyDescriptor SourcePropertyName="PIMCO_DESC" HierarchyName="{x:Static local:TBARollBook.kViewProduct}"> <igFlatData:HierarchyDescriptor.LevelDescriptors> <igFlatData:HierarchyLevelDescriptor LevelName="All"/> <igFlatData:HierarchyLevelDescriptor LevelName="Product" LevelExpressionPath="PIMCO_DESC"/> </igFlatData:HierarchyDescriptor.LevelDescriptors> </igFlatData:HierarchyDescriptor> <igFlatData:HierarchyDescriptor SourcePropertyName="BROKER" HierarchyName="{x:Static local:TBARollBook.kViewBroker}"> <igFlatData:HierarchyDescriptor.LevelDescriptors> <igFlatData:HierarchyLevelDescriptor LevelName="All"/> <igFlatData:HierarchyLevelDescriptor LevelName="Broker" LevelExpressionPath="BROKER"/> </igFlatData:HierarchyDescriptor.LevelDescriptors> </igFlatData:HierarchyDescriptor> </igFlatData:FlatDataSource.HierarchyDescriptors> </igFlatData:FlatDataSource> </UserControl.Resources> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <localControls:Toolbar/> <StackPanel Grid.Row="0" Orientation="Horizontal"> <StackPanel.Resources> <Style TargetType="{x:Type GroupBox}"> <Setter Property="Margin" Value="2"/> </Style> </StackPanel.Resources> <GroupBox Header="Options" Foreground="White" Template="{DynamicResource MainGroupBoxControlTemplate}"> <StackPanel Orientation="Horizontal"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <Grid.Resources> <Style TargetType="{x:Type ComboBox}"> <Setter Property="Width" Value="150"/> <Setter Property="Margin" Value="4"/> <Setter Property="VerticalAlignment" Value="Center"/> </Style> <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource {x:Type TextBlock}}"> <Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="Margin" Value="4"/> </Style> </Grid.Resources> <TextBlock Text="Delivery Date" Grid.Row="0" Grid.Column="0"/> <ComboBox Grid.Row="0" Grid.Column="1" ItemsSource="{Binding DeliveryDates}" SelectionChanged="OnDeliveryChanged" SelectedItem="{Binding SelectedDelivery}"/> <TextBlock Text="Portfolio Manager" Grid.Row="1" Grid.Column="0" Width="100"/> <ComboBox Grid.Row="1" Grid.Column="1" ItemsSource="{Binding PortfolioManagers}" SelectionChanged="OnPMChanged" SelectedItem="{Binding SelectedPMs}"/> <!--<ig:XamMultiColumnComboEditor Name="PMFilter" Grid.Row="1" Grid.Column="1" ItemsSource="{Binding PortfolioManagers}" EmptyText="All" DisplayMemberPath="Name" AllowDropDownResizing="True" AllowMultipleSelection="True" CheckBoxVisibility="Visible" SelectedItemsResetButtonVisibility="Visible" SelectionChanged="OnPMChanged" Margin="4" Width="150"> <ig:XamMultiColumnComboEditor.Columns> <ig:TextComboColumn Key="Name" HeaderText="PM"/> </ig:XamMultiColumnComboEditor.Columns> </ig:XamMultiColumnComboEditor>--> <CheckBox IsChecked="{Binding IsRollAll}" Content="Include Do Not Roll" Click="OnRollChanged" Style="{StaticResource PoolmanCB}" Grid.Row="1" Grid.Column="2"/> <CheckBox Name="NetFails" IsChecked="{Binding IsNetFails}" Content="Include Failing Positions" Click="OnFailsChanged" Style="{StaticResource PoolmanCB}" Grid.Row="0" Grid.Column="2"/> </Grid> </StackPanel> </GroupBox> <GroupBox Header="Book" Foreground="White" Template="{DynamicResource MainGroupBoxControlTemplate}"> <StackPanel> <CheckBox IsChecked="{Binding IsLastRoll}" Content="{x:Static local:TBARollBook.kBookLast}" Click="OnBookChanged" Style="{StaticResource PoolmanCB}" IsEnabled="False"/> <CheckBox IsChecked="{Binding IsLiveRoll}" Content="{x:Static local:TBARollBook.kBookLive}" Click="OnBookChanged" Style="{StaticResource PoolmanCB}"/> <CheckBox IsChecked="{Binding IsMustRoll}" Content="{x:Static local:TBARollBook.kBookMust}" Click="OnBookChanged" Style="{StaticResource PoolmanCB}"/> </StackPanel> </GroupBox> <GroupBox Header="View" Foreground="White" Template="{DynamicResource MainGroupBoxControlTemplate}"> <StackPanel> <StackPanel.Resources> <Style TargetType="{x:Type RadioButton}"> <Setter Property="Margin" Value="4"/> <Setter Property="Foreground" Value="White"/> </Style> </StackPanel.Resources> <RadioButton IsChecked="{Binding IsProductView}" GroupName="View" Content="Product" Tag="{x:Static local:TBARollBook.kViewProduct}" Click="OnViewChanged"/> <RadioButton IsChecked="{Binding IsBrokerView}" GroupName="View" Content="Broker" Tag="{x:Static local:TBARollBook.kViewBroker}" Click="OnViewChanged"/> <RadioButton IsChecked="{Binding IsAccountView}" GroupName="View" Content="Account" Tag="{x:Static local:TBARollBook.kViewAccount}" Click="OnViewChanged"/> </StackPanel> </GroupBox> <GroupBox Header="Turn" Foreground="White" Template="{DynamicResource MainGroupBoxControlTemplate}"> <StackPanel> <CheckBox IsChecked="{Binding IsTurnYes}" Content="Yes" Click="OnTurnChanged" Style="{StaticResource PoolmanCB}"/> <CheckBox IsChecked="{Binding IsTurnNo}" Content="No" Click="OnTurnChanged" Style="{StaticResource PoolmanCB}"/> </StackPanel> </GroupBox> <StackPanel Orientation="Horizontal"> <StackPanel.Resources> <Style TargetType="{x:Type Button}" BasedOn="{StaticResource ChromelessButton}"> <Setter Property="VerticalAlignment" Value="Bottom"/> <Setter Property="Margin" Value="4"/> <Setter Property="Foreground" Value="White"/> <Setter Property="Width" Value="46"/> </Style> </StackPanel.Resources> <Button Click="OnRefresh"> <StackPanel> <Image Source="..\Images\refresh.ico" Style="{DynamicResource SmallImage}"/> <TextBlock Text="Refresh" Style="{DynamicResource ChromelessButtonLabel}"/> </StackPanel> </Button> <Button Click="ExcelButton_Click"> <StackPanel> <Image Source="..\Images\excel.png" Style="{DynamicResource SmallImage}"/> <TextBlock Text="Excel" Style="{DynamicResource ChromelessButtonLabel}"/> </StackPanel> </Button> </StackPanel> </StackPanel> <igPivot:XamPivotGrid Name="RollGrid" Grid.Row="1" Visibility="Visible" AllowCompactLayout="True" Loaded="OnLoaded" CellDoubleClicked="OnDrillDown" TotalRowStyle="{StaticResource TotalRowCellStyle}" CellStyle="{StaticResource ShortStyle}" DataSource="{StaticResource RollBookDataSource}" BorderBrush="{x:Null}" BorderThickness="0"> <i:Interaction.Behaviors> <Behaviors:PivotCellColorBehavior ItemsSource="{Binding BrokerColors}" ForegroundColor="White"/> <Behaviors:PivotGridAutoWidthBehavior/> <Behaviors:SectionShaderBehavior ColumnName="Live" CellStyle="{StaticResource CellStyle}" TotalCellStyle="{StaticResource TotalCellStyle}"/> <Behaviors:PivotGridMouseOverCellBehavior ClickRightClicked="OnCellRightClicked"/> </i:Interaction.Behaviors> <igPivot:XamPivotGrid.SelectionSettings> <igPivot:PivotSelectionSettings RowSelection="None" ColumnSelection="None"/> </igPivot:XamPivotGrid.SelectionSettings> <igPivot:XamPivotGrid.ContextMenu> <ContextMenu> <MenuItem Header="Send to Execution" Command="{Binding ContextMenuCommand}"> <MenuItem.Icon> <Image Width="16" Height="16" Source="../Images/upload.ico"/> </MenuItem.Icon> </MenuItem> </ContextMenu> </igPivot:XamPivotGrid.ContextMenu> </igPivot:XamPivotGrid> <igDP:XamDataGrid Name="AccountGrid" Grid.Row="1" Visibility="Collapsed" DataSource="{Binding ResultPositions}" GroupByAreaLocation="None" AutoFit="False"> <igDP:XamDataGrid.FieldSettings> <igDP:FieldSettings AllowEdit="False" AllowRecordFiltering="True" FilterLabelIconDropDownType="MultiSelectExcelStyle" SummaryDisplayArea="BottomFixed" CellClickAction="SelectRecord"/> </igDP:XamDataGrid.FieldSettings> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings AutoFitMode="ExtendLastField" AllowDelete="False" AllowAddNew="False" AllowFieldMoving="WithinLogicalRow" AutoGenerateFields="False" HighlightAlternateRecords="True" RecordSelectorLocation="None" FilterUIType="LabelIcons"/> </igDP:XamDataGrid.FieldLayoutSettings> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:FieldLayout.SortedFields> <igDP:FieldSortDescription Direction="Ascending" FieldName="ACCT_NO"/> </igDP:FieldLayout.SortedFields> <igDP:FieldLayout.Fields> <igDP:Field Name="DELIVERY_DT" Label="Delivery"/> <igDP:Field Name="ACCT_NO" Label="Account"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource PoolmanDecimalStyle}"/> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="PM_NAME" Label="PM"/> <igDP:Field Name="PIMCO_DESC" Label="Security"/> <igDP:Field Name="BROKER" Label="Broker"> <igDP:Field.Settings> <igDP:FieldSettings CellValuePresenterStyle="{StaticResource BrokerCell}"/> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="LONG_QTY" Label="Long"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource AmountStyle}"/> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="SHORT_QTY" Label="Short"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource AmountStyle}"/> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="Net"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource AmountStyle}"/> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="LIVE_LONG_QTY" Label="Long (Live)"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource AmountStyle}"/> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="LIVE_SHORT_QTY" Label="Short (Live)"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource AmountStyle}"/> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="LiveNet" Label="Net (Live)"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource AmountStyle}"/> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="MUST_ROLL_LONG_QTY" Label="Long (Must Roll)"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource AmountStyle}"/> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="MUST_ROLL_SHORT_QTY" Label="Short (Must Roll)"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource AmountStyle}"/> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="MustRollNet" Label="Net (Must Roll)"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource AmountStyle}"/> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="ROLL_IND" Label="Roll"/> <igDP:Field Name="TURN_IND" Label="Turn"/> <igDP:Field Name="TKD_IND" Label="TKD"/> </igDP:FieldLayout.Fields> <igDP:FieldLayout.SummaryDefinitions> <igDP:SummaryDefinition SourceFieldName="LONG_QTY" Calculator="Sum" StringFormat="{}{0:#,#;(#,#)}"/> <igDP:SummaryDefinition SourceFieldName="SHORT_QTY" Calculator="Sum" StringFormat="{}{0:#,#;(#,#)}"/> <igDP:SummaryDefinition SourceFieldName="Net" Calculator="Sum" StringFormat="{}{0:#,#;(#,#)}"/> <igDP:SummaryDefinition SourceFieldName="LIVE_LONG_QTY" Calculator="Sum" StringFormat="{}{0:#,#;(#,#)}"/> <igDP:SummaryDefinition SourceFieldName="LIVE_SHORT_QTY" Calculator="Sum" StringFormat="{}{0:#,#;(#,#)}"/> <igDP:SummaryDefinition SourceFieldName="LiveNet" Calculator="Sum" StringFormat="{}{0:#,#;(#,#)}"/> <igDP:SummaryDefinition SourceFieldName="MUST_ROLL_LONG_QTY" Calculator="Sum" StringFormat="{}{0:#,#;(#,#)}"/> <igDP:SummaryDefinition SourceFieldName="MUST_ROLL_SHORT_QTY" Calculator="Sum" StringFormat="{}{0:#,#;(#,#)}"/> <igDP:SummaryDefinition SourceFieldName="MustRollNet" Calculator="Sum" StringFormat="{}{0:#,#;(#,#)}"/> </igDP:FieldLayout.SummaryDefinitions> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> </igDP:XamDataGrid> </Grid></UserControl>
I'm not sure about the reason but if you post the working one I can look at it so we can find the difference. Also I've noticed that I have no email notification about the last post I wrote at this thread yesterday and I guess you haven't such notification too. There I've put some code that has fixed ExpandDimensions() and some improvements about filtering as well.