Hi Martin,
We have analyzed the provided sample and performance of summary calculating can be optimized using INotifyPropertyChanging and INotifyPropertyChanged. Below documentation explains the same.
In your sample, you have implemented the interfaced but not in the right way where SfDataGrid can listen to notification and performance summary calculation optimistically.
For example, Before changing the property you have to call PropertyChanging event, So SfDataGrid will know the property going to be changed and store its previous value internally. After changing the value, you have to trigger PropertyChanged event, So now SfDataGrid recalculates the summary based on old value and new value optimistically without reading entire column of values.
public double? A
{
get { return A_; }
set
{
//Raising property changing before it gets changed to backup the old value
this.MultiPropertyChanging("A");
A_ = value;
this.MultiPropertyChanged("A");
this.UpdateProperty("D", "E", "F", "G", "H", "I", "J", "K");
//this.MultiPropertyChanging("D", "E", "F", "G", "H", "I", "J", "K");
//this.MultiPropertyChanged("D", "E", "F", "G", "H", "I", "J", "K");
if (Table1 != null)
{
Table1.OnPropertyChanged("A");
Table1.OnPropertyChanging("A");
}
}
} |
In the same way, Other properties D, E, F, G, H, I, J, K changed to optimistically calculate the summary.
internal void UpdateProperty(params string[] Prop)
{
foreach (var propertyName in Prop)
{
if(propertyName == "D")
D = A + B;
if (propertyName == "E")
E = A + C;
if (propertyName == "F")
F = D + E;
if (propertyName == "G")
G = F + C;
if (propertyName == "H")
H = F + G;
if (propertyName == "I")
I = G + H;
if (propertyName == "J")
J = E + I;
if (propertyName == "K")
K = I + J;
}
}
private double? D_;
public double? D
{
get { return D_; }
set
{
OnPropertyChanging("D");
D_ = value;
OnPropertyChanged("D");
}
//get { return A + B; }
} |
Please find the modified sample below,
Thanks,
Sivakumar