Refreshing cell after update

I use a grid to display some data.

2 of the columns are editable. when I change content of 1 cell for column 1, the second column cell's value is updated but I only see the new value when I get into edit mode of the second column's cell.

If i refresh the ItemSource, my new value shows, but the entire grid is reloaded and it's confusing and we lose focus on the current cell.

Is there a method I call call to force refresh of a given cell after cellEndEdit or anywhere else for that matter.

16 Replies

SK Shivagurunathan Kamalakannan Syncfusion Team January 17, 2018 03:01 AM UTC

Hi Fred Morin, 
 
We have checked your query. Your requirement to update the value in second column while changing the value in column 1 can be achieved in SfDataGrid. Your requirement can be achieved by using the SfDataGrid.CurrentCellEndEdit event. 
 
 
 
Note: Implement INotifyPropertyChanged to avoid update issues. 
 
 
 
Refer the below code for more details. 
 
 
public partial class MainPage : ContentPage 
{ 
    public MainPage() 
    { 
        InitializeComponent(); 
        dataGrid.GridLoaded += DataGrid_GridLoaded; 
    } 
 
    public void EditCall() 
    { 
       dataGrid.CurrentCellEndEdit += DataGrid_CurrentCellEndEdit; 
       dataGrid.Refreshed(); 
    } 
 
    private void DataGrid_CurrentCellEndEdit(object sender, GridCurrentCellEndEditEventArgs e) 
    { 
        var data = dataGrid.GetRowGenerator().Items.FirstOrDefault(x =>x.RowIndex == e.RowColumnIndex.RowIndex).RowData as OrderInfo; 
        if (data.CustomerID != null) 
        { 
            data.CustomerID = "Changed"; 
        } 
    } 
    private void DataGrid_GridLoaded(object sender, GridLoadedEventArgs e) 
    { 
        dataGrid.BeginEdit(2, 2); 
        this.EditCall(); 
    } 
} 
 
 
If you face any issues in updating the cell values. It would be helpful to us if you can provide us any of the following: 
 
  • Can you share us the Xaml page containing SfDataGrid so that we could reproduce the issue?
  • What are the settings that are given to the SfDataGrid?
  • Can you able to provide the modified sample that reproduce the issue.
 
We have prepared a sample based on your requirement and you can download the same from the below link. 
 
Regards, 
Shivagurunathan. K 
 



AN Andy February 26, 2019 08:37 AM UTC

Hi, 

i want to change the value of a cell in code and tested your example in this thread (Sample Link: http://www.syncfusion.com/downloads/support/directtrac/general/ze/SfGrid_Sample-177656109). 

I expected that when I double tap into a cell and leave it the new value text of the cell is "Changed" but the grid shows the old value.

Can you help me to solve that?


Thanks!



SP Subburaj Pandian Veluchamy Syncfusion Team February 27, 2019 11:24 AM UTC

Hi Fred, 
  
Thank you for contacting Syncfusion support. 
  
Query 1: Change the value of the cell. 
 
Your requirement of “Changing the value of the cell” can be achieved, please refer the following code example for the same. 
  
[C#] 
//When the Cell is in view use this code. 
  
var data = dataGrid.GetRowGenerator().Items.FirstOrDefault(x =>x.RowIndex == e.RowColumnIndex.RowIndex).RowData as OrderInfo; 
if (data.CustomerID != null) 
{ 
    data.CustomerID = "Changed"; 
} 
  
// if you want to update the cell which is not in view, you can use as below. 
// It’s just enough to change the underlaying collection. 
  
viewModel.OrderInfoCollection[5].CustomerID = "Changed"; 
 
 
  
Query 2: Edit and commit the cell value it shows old value. 
  
We have checked this query in shared sample it is working fine from our end. We have attached the video for your reference. 
  
 
Could you please check the video and let us know with the following details? 
·        Syncfusion product version and issue reproducing video 
·       Elaborate your requirement. 
 
Kindly modify the sample based on your scenario and revert to us with more details the exact replication procedure to replicate the issue. It will be helpful for us to check on it and provide you the solution at the earliest. 
 
Regards,
Subburaj Pandian V  



AN Andy March 5, 2019 09:05 AM UTC

Hi,

with your example and the OrderInfo Model it works. But when I use my auto-generated SOAP model as Model for the ObservableCollection it only update on scrolling the List. The model inhertis from PropertyChanged.
I've attached my classes, maybe you know why it doesn't update? 

- My Observable Collection is ObservableCollection<FaZuordnungItem> FaList in RessourcenplanungViewModel.cs
- FaZuordnungItem is in MobileService.cs

- With the Button ChangeBezeichnung in MainAuftraegeZuweisen.xaml.cs it changes the text but only when I scroll the list:

        private  void ChangeBezeichnung(object sender, EventArgs e)
        {
            viewModel.FaList[5].FaItem.ZusatzInfo = "CHANGED";
        }

Thank you :)


Maria

Attachment: ObservableCollectionNoUpdate_b2970053.zip


PK Pradeep Kumar Balakrishnan Syncfusion Team March 6, 2019 01:11 PM UTC

Hi Maria, 
 
Thank you for update. 
 
Currently, we are validating the reported issue “Property changed is not working” with the provided details. we will let you know the further details in two days March 8, 2019 We appreciate your patience until then.  
 
Regards, 
Pradeep Kumar B 
 
 



PK Pradeep Kumar Balakrishnan Syncfusion Team March 9, 2019 10:27 AM UTC

Hi Maria, 
 
Thank you for your patience. 
 
we have checking on the datagrid with SOAP model. We are working on this to replicate the issue. we will update the further details in two business days March 12 , 2019 . we appreciate your patience until then. 
 
Regards, 
Pradeep   



PK Pradeep Kumar Balakrishnan Syncfusion Team March 12, 2019 07:19 PM UTC

Hi Maria,

Thank you for your patience.

We have checked the shared Model and ViewModel codes in that you have converted into list of items and then added those items in observable collection. Hence we have prepared the sample with the same use case but the issue is not reproduced for us. Can you please modify the below sample to reproduce the issue. To resolve the issue earlier for you.

Sample link : http://www.syncfusion.com/downloads/support/forum/135425/ze/sample-182563154

Regards,

Pradeep Kumar b




AN Andy March 13, 2019 10:04 AM UTC

Hi,

I modified the example and I can reproduce my issue with it. 
In the AsyncServer.cs I manually fill the collection model as it filled in my server component.

Thanks for your help!

Maria

Attachment: sample182563154_952c49da.zip


SP Subburaj Pandian Veluchamy Syncfusion Team March 14, 2019 12:00 PM UTC

Hi Maria, 
  
Thank you for the sample. 
  
We have checked your sample and we can able to replicate the issue “property changed is not working in Soap Model”. Currently we are validating the reported issue why property changed notification is not triggering our DataGrid property changed event but underlaying collection is changed. We will validate and update you the details in two business days (March 18, 2019). We appreciate your patience and please use following code until then to change the value. 
  
[C#] 
private void ChangeBezeichnung(object sender, EventArgs e) 
{ 
    viewModel.FaList[2].FaItem.ZusatzInfo = "CHANGED"; 
    var dataRow = dgAuftraege.GetRowGenerator().Items.FirstOrDefault((x => x.RowData == viewModel.FaList[2])); 
    dgAuftraege.UpdateDataRow(dataRow.RowIndex); 
    dgAuftraege.Refresh(); 
} 
  
Regards,
Subburaj Pandian V    



SP Subburaj Pandian Veluchamy Syncfusion Team March 19, 2019 12:47 PM UTC

Hi Maria, 
  
We have analyzed the issue “Property changed in soap model is not working” and found that property changed is raised but the property changed event is null hence the raise property changed is not working on your sample we are analyzing the sample to find why the property changed event is null. We will update the further response in three business days (March 22, 2019). We appreciate your patience until then. 
 
Regards,
Subburaj Pandian V  



SK Shivagurunathan Kamalakannan Syncfusion Team March 23, 2019 05:11 AM UTC

Hi Maria, 
 
Thanks for you patience. 
 
We confirmed that the issue with “Edited values does not get committed with complex properties” is a defect and we have logged a defect report. The fix for this issue is estimated to be available in the upcoming release 2019 volume 1 service pack 1 which is scheduled to be rolled by the end of April. 
                         
Regards, 
Shivagurunathan 



AN Andy March 29, 2019 09:52 AM UTC

Thank you for your feedback and your help! We will wait until the update is released.


SP Subburaj Pandian Veluchamy Syncfusion Team March 29, 2019 09:58 AM UTC

Hi Maria, 
 
Thank you for the update.  
 
As mentioned, we will include the issue fix in our Volume 1 SP1 release and let you know once it has been rolled out. We appreciate your patience until then.   
 
Regards,
Subburaj Pandian V 



SP Subburaj Pandian Veluchamy Syncfusion Team April 15, 2019 11:39 AM UTC

 
Hi Maria,  
  
Sorry for the inconvenience caused. 
 
After further analysis, as the limitation of listening the complex property value changes, we can’t provide the fix in source level. But we would suggest you to use following code in the sample level to listen the property value changes. In the below solution, you need to hook the property changed event for complex property to listen that property at our source. 
  
Please check your application with the below code snippet, 
  
  
[System.Runtime.Serialization.DataMemberAttribute()] 
public ias.officeline.mobileservice.ppsFaRueckmeldungItem FaItem 
{ 
    get 
    { 
        return this.FaItemField; 
    } 
    set 
    { 
        if ((object.ReferenceEquals(this.FaItemField, value) != true)) 
        { 
            this.FaItemField = value; 
            this.RaisePropertyChanged("FaItem"); 
  
            //// You need to hook property changed event for complex proeperty. 
            this.FaItem.PropertyChanged += FaItem_PropertyChanged; 
        } 
    } 
} 
  
private void FaItem_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) 
{ 
//ensure to provide the proper complex property name in below, 
    RaisePropertyChanged("FaItem." + e.PropertyName); 
} 
  
               
We have attached the sample for your reference, 
 
 
Please check the provided solution and let us know if you have any concern. 
 
Regards,
Subburaj Pandian V



AN Andy April 29, 2019 05:53 AM UTC

Hi, 

I can't use this workaround in your code snippet because as I wrote my SOAP model is auto-generated (with the microsoft tool SvcUtil.exe). If I change it, it will be removed after every server contracts update.


SP Subburaj Pandian Veluchamy Syncfusion Team April 30, 2019 01:20 PM UTC

Hi Maria, 
  
Thank you for the update.

 
We have checked your query and you can set LoadUiView as true to the columns. By default, the “LoadUIView” for the GridColumn is set as false. SfDataGrid will load a label inside the GridCells instead of drawing the contents in Android when the GridColumn.LoadUIView is true. 
  
We have attached the sample for your reference, 
 
  
Please let us know, if you have any query. 
 
Regards,
Subburaj Pandian V   


Loader.
Up arrow icon