Hi,
I am using MVVM pattern to build a Pivot table per user's request. Because of the MVVM pattern, I define the LocalDataSourceProvider for the pivot grid and assign its ItemsSource in the ViewModel. My issue is that the pivot is showing the data that was assigned to the ItemsSource first time. E.g.: When I bind the the ItemsSource to my list on first time, the Pivot is showing the correct data on screen. After that, no matter how I change the ItemsSource, the Pivot is always showing the data assinged on the first assignment.
Here is the code that relate to the issue.
In xaml:
<pivot:RadPivotGrid x:Name="pivot1" Grid.Column="0" DataProvider="{Binding DataSource}"
VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5"
UseLayoutRounding="False" d:LayoutRounding="Auto" FontSize="10" >
</pivot:RadPivotGrid>
<pivot:RadPivotFieldList Grid.Column="1" DataProvider="{Binding DataSource}" Margin="-1,0,1,0" FontSize="10" />
In ViewModel:
private LocalDataSourceProvider _dataSource;
public LocalDataSourceProvider DataSource
{
get { return _dataSource; }
set
{
_dataSource = value;
RaisePropertyChanged("DataSource");
}
}
private void InitialDataSource()
{
_dataSource = new LocalDataSourceProvider();
_dataSource.RowGroupDescriptions.Add(new PropertyGroupDescription { PropertyName = "ProductType" });
_dataSource.RowGroupDescriptions.Add(new PropertyGroupDescription { PropertyName = "CashType" });
_dataSource.ColumnGroupDescriptions.Add(new DateTimeGroupDescription { PropertyName = "ValueDate",Step=DateTimeStep.Day});
_dataSource.AggregateDescriptions.Add(new PropertyAggregateDescription { PropertyName = "Value", StringFormat = "#,#; -#,#" });
}
private void GetDataSource()
{
DataSource.ItemsSource = _reports;
RaisePropertyChanged("DataSource");
}
A button click event will trigger re-assignment of the _reports and calls the GetDataSource function.
Please take a look and let me know how I can correct.
Many thanks,
guobian
I am using MVVM pattern to build a Pivot table per user's request. Because of the MVVM pattern, I define the LocalDataSourceProvider for the pivot grid and assign its ItemsSource in the ViewModel. My issue is that the pivot is showing the data that was assigned to the ItemsSource first time. E.g.: When I bind the the ItemsSource to my list on first time, the Pivot is showing the correct data on screen. After that, no matter how I change the ItemsSource, the Pivot is always showing the data assinged on the first assignment.
Here is the code that relate to the issue.
In xaml:
<pivot:RadPivotGrid x:Name="pivot1" Grid.Column="0" DataProvider="{Binding DataSource}"
VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5"
UseLayoutRounding="False" d:LayoutRounding="Auto" FontSize="10" >
</pivot:RadPivotGrid>
<pivot:RadPivotFieldList Grid.Column="1" DataProvider="{Binding DataSource}" Margin="-1,0,1,0" FontSize="10" />
In ViewModel:
private LocalDataSourceProvider _dataSource;
public LocalDataSourceProvider DataSource
{
get { return _dataSource; }
set
{
_dataSource = value;
RaisePropertyChanged("DataSource");
}
}
private void InitialDataSource()
{
_dataSource = new LocalDataSourceProvider();
_dataSource.RowGroupDescriptions.Add(new PropertyGroupDescription { PropertyName = "ProductType" });
_dataSource.RowGroupDescriptions.Add(new PropertyGroupDescription { PropertyName = "CashType" });
_dataSource.ColumnGroupDescriptions.Add(new DateTimeGroupDescription { PropertyName = "ValueDate",Step=DateTimeStep.Day});
_dataSource.AggregateDescriptions.Add(new PropertyAggregateDescription { PropertyName = "Value", StringFormat = "#,#; -#,#" });
}
private void GetDataSource()
{
DataSource.ItemsSource = _reports;
RaisePropertyChanged("DataSource");
}
A button click event will trigger re-assignment of the _reports and calls the GetDataSource function.
Please take a look and let me know how I can correct.
Many thanks,
guobian