We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Online update summary

Hello,

i have problem with "LiveDataUpdateMode" in SfDataGrid. I found new solution for table structure with using dictionary as source data. This solution doesn't work in older syncfusion version, but now it works (especialy using "OnPropertyChanged(Binding.IndexerName)" as property changed event). But summary doesn't change own values. If i use old schema with two properties and OnPropertyChanging and OnPropertyChanged, it works, but code for larges tables is too long.

Is any way, to update summary using this new system? Everything is in example in attachement.

Thanks for help
Martin

Attachment: TestWPF_f925c83a.zip

5 Replies

SV Srinivasan Vasu Syncfusion Team May 24, 2017 03:43 AM UTC

 
Hi Martin, 
 
Thanks for contacting Syncfusion support. 
 
We have checked your sample. The PropertyChanging event handled while changing the propertyvalue. Once the value has been changed, the PropertyChanged event triggered. In your sample, you have passed Binding.IndexerName instead of PropertyName. In our source, we have update the summary value based on PropertyName. The Binding.IndexerName default value is “Item[]”. So, that summary value not updated properly because property changed not notified. You should pass PropertyName(MappingName) into notify property changed for update the SummaryValue. Could you please modifying your sample by passing the PropertyName into PropertyChanged event to resolve your reported problem. 
 
 
public object this[string key] 
        { 
            get { 
 
                return this.Data?[key]; 
 
            } 
            set { 
               
                OnPropertyChanging(Binding.IndexerName); 
                this.Data[key] = value; 
                OnPropertyChanged(Binding.IndexerName); 
 
            } 
        } 
 
 
 
Regards, 
Srinivasan 



MT Martin Tichovsky May 24, 2017 04:17 AM UTC

Hello,

i know what you write, but my problem is more specific. At first, i could passing OnPropertyChanged("C") as calling event for changed value, but in newer syncfusion version work OnPropertyChanged(Binding.IndexerName) as well. If you change in the sample in first tab column A or B any value, C column will be recalculating, but summary not. If C column changes own value with using "Item[]" as property name i expect, that do even summary.

At second, imagine this. I have more than twenty tables, each linked together, with tens of columns. Each column value have link to other data resource or doing math with them. If i will have to find each column, which will be changed, and if i will have to write list of property names, its hard work and too many spaces for mistakes. I can use this OnPropertyChanged("") for updating all columns, but this call has slow effect on tables.

Therefore i ask for better solution.


SR Sivakumar R Syncfusion Team May 26, 2017 01:38 PM UTC

Hi Martin, 
 
Using OnPropertyChanged(“”) is not an effective way to calculate or refresh View, as it will consider all properties gets changed. I have modified the your sample to maintain the linking in dictionary and update it when property gets changed. Please find the details below, 
 
We have created two dictionary to maintain mapping details of class and dependent class.  
public class TableData_1 : TableData 
{ 
    Dictionary<string, string[]> ProperyMapping = new Dictionary<string, string[]>() 
    { 
        { "A", new string[] {"C"} }, 
        { "B", new string[] {"C"} } 
    }; 
 
    Dictionary<string, string[]> DependentMapping = new Dictionary<string, string[]>() 
    { 
        { "A", new string[] { "GA" } }, 
        { "B", new string[] { "GB" } } 
    }; 
} 
 
And in UpdateProperties method, dependent properties and dependent class properties changes notified on property basics. 
public override void UpdateProperties([CallerMemberName] string propertyName = null) 
{ 
    base.UpdateProperties(propertyName); 
    if(ProperyMapping.ContainsKey(propertyName)) 
    { 
        foreach (var dependentPropertyName in ProperyMapping[propertyName]) 
        { 
            OnPropertyChanged(dependentPropertyName); 
        } 
    } 
    if (DependentMapping.ContainsKey(propertyName)) 
    { 
        foreach (var dependentPropertyName in DependentMapping[propertyName]) 
        { 
            this.TD2.OnPropertyChanged(dependentPropertyName); 
        } 
    } 
} 
 
In this way, summary will get calculated in very optimistic way. Please find the modified sample below, 
 
Thanks, 
Sivakumar 



MT Martin Tichovsky May 30, 2017 11:58 AM UTC

Hello, 

new example is still much complex to change all dependencies in large tables. I have another question. Is it possible mapping value from class index? Something like MappingName="[A]" which summaries and changing values still work? I sending example which doesn't work properly.

Attachment: TestSample_7b82416c.zip


SV Srinivasan Vasu Syncfusion Team May 31, 2017 06:03 PM UTC

Hi Martin, 
 
We have checked your sample. We cannot set the mapping name as you have mentioned. You have passed Binding.IndexerName instead of PropertyName in OnPropertyChanged method. Since the Binding.IndexerName always returns the default value (Item[]), the changed property name (MappingName) is not correctly notified in the OnPropertyChanged.  
 
You can meet this requirement only by passing the property name to the OnPropertyChanged as mentioned in our previous update.  
 
In our previous update, we have passed the dependency property name to OnPropertyChanged to update the corresponding property value and dependent value. Initially, we have stored the corresponding property name and dependent property name in a dictionary to update when the other property changes. 
 
Please refer the below code example. 
 
Dictionary<string, string[]> ProperyMapping = new Dictionary<string, string[]>() 
        { 
            { "A", new string[] {"C"} }, 
            { "B", new string[] {"C"} } 
        }; 
 
 
 
public override void UpdateProperties([CallerMemberName] string propertyName = null) 
        { 
            base.UpdateProperties(propertyName); 
            if(ProperyMapping.ContainsKey(propertyName)) 
            { 
                foreach (var dependentPropertyName in ProperyMapping[propertyName]) 
                { 
                    OnPropertyChanged(dependentPropertyName); 
                } 
            } 
            if (DependentMapping.ContainsKey(propertyName)) 
            { 
                foreach (var dependentPropertyName in DependentMapping[propertyName]) 
                { 
                    this.TD2.OnPropertyChanged(dependentPropertyName); 
                } 
            } 
        } 
 
 
In our source, we have updated the summary value only based on the bound PropertyName (MappingName of the corresponding column). Since you have passed the property name as Binding.IndexerName which has the default value as “Item[]” the summary values are not updated properly as the property with name “Item[]” will not be available in the bound collection. Hence, you must pass PropertyName (MappingName) to notify the property changed for the SummaryValue updation.  
 
Also, the C column value updated while changing B or A column value due to setting UseDrawing property as Default in SfDataGrid. Because, While using UseDrawing in SfDataGrid we have invalidate the entire row object to draw the contents whenever a cell value of any column is changed. 
 
There is no other way to meet your requirement without passing PropertyName to OnPropertyChanged method. 
 
public object this[string key] 
        { 
            get 
            { 
                return this.Data[key]; 
            } 
            set 
            {                 
 
// This is not a recommended way to update the summary value and corresponding cell value. 
                OnPropertyChanging(Binding.IndexerName);                        
                this.Data[key] = value; 
                OnPropertyChanged(Binding.IndexerName);                        
            } 
        } 
     
 
 
Please let us know if you neeed further assistance on this. 
 
 
Regards, 
Srinivasan 
 


Loader.
Live Chat Icon For mobile
Up arrow icon