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

Active Cell Edit not bound before OnNavigatingFrom is called

I have a grid with 4 textboxes.  I enter data, but then leave the cursor in the 4th spot and click the BackButton.  The bound values of the first 3 cells immediately trigger the INotifyPropertyChanged event, but THEN the OnNavigatingFrom gets called and then finally the 4th cell triggers the INotifyPropertyChanged event.

I need the 4th cell to bind BEFORE the OnNavigatingFrom method is called.  Is there some event I can call that will force the datagrid to complete the binding?  

I have tried:
moving the focus out of the cell programmatically with FocusManager.TryMoveFocus
setting the focus onto a specific control
Manually calling Bindings.Update();

I have seen that in WPF the datagrid has a CellEditEnding event that can be triggered to accomplish this.  Is there something like that available here?  Or any idea on what else I can do?

thanks!
Deanna


8 Replies

SP Sowndaiyan Paulpandi Syncfusion Team July 20, 2016 12:17 PM UTC

Hi Deanna,

Thanks for contacting Syncfusion support.

 
We have checked your queries. Please find the details below.    

Query 1 [OnNavigatingFrom wrongly called]

We have prepared the sample as per your scenario and also checked your reported issue. But we were unable to reproduce the reported issue in our sample and in this sample “OnNavigatingFrom” is called after the INotifyPropertyChanged event of all properties. For your reference we have attached the tested sample in the below location.
Please revert by modifying the attached sample based on your application along with the replication procedure and also share the details about which Syncfusion product version you have used in your application. It will be helpful for us to analyze further. 

Sample :
http://www.syncfusion.com/downloads/support/forum/125070/ze/UWP2070027976
 
 
Query 2[CellEditEnding Event]

In SfDataGrid, you can use CurrentCellEndEdit event likewise DataGrid.CellEditEnding event. It will be occur when the CurrentCell exits the edit mode. You can trigger the CurrentCellEndEdit event like the below code example,
 

C# 
this.dataGrid.CurrentCellBeginEdit += DataGrid_CurrentCellBeginEdit; 
private void DataGrid_CurrentCellBeginEdit(object sender, CurrentCellBeginEditEventArgs args)
  {
  }

Regards,

Sowndaiyan
 
 



DD Deanna Delapasse July 20, 2016 09:56 PM UTC

I have modified your example to show the problem. I added a hamburger menu and  enabled the back button.  Make sure the VS console is open so you can see the  debug statements.

1) Click "Main"
2) Change row 105's EmployeeSalary  to "123"
3) Change row 106's EmployeeSalary  to "456" but do not leave the cell
4) Click the back button at the top left of the app

The events are in this order:
EmployeeSalary setter: 123
Inside OnNavigatedFrom
EmployeeSalary setter: 456

I need some way to trigger the Employee setter BEFORE I execute some logic in the OnNavigatedFrom method (I can add logic at the beginning of this method - but not sure what would work).  Please help!  I have tried a few options (forcing the focus) but it's not working.

thanks very much for your help!
Deanna

Attachment: UWP_1a38c46c.zip


DD Deanna Delapasse July 21, 2016 01:51 PM UTC

Let me know if you can't reproduce this.  I can make a movie for you.


SP Sowndaiyan Paulpandi Syncfusion Team July 22, 2016 02:54 AM UTC

Hi Deanna,

We have checked your reported issue in our SfDataGrid. You can resolve your problem by setting the UpdateSourceTrigger as PropertyChanged for the TextBox like the below code example, 
  <syncfusion:GridTemplateColumn MappingName="EmployeeSalary"  > 
                    <syncfusion:GridTemplateColumn.CellTemplate> 
                        <DataTemplate> 
                            <TextBlock Text="{Binding EmployeeSalary}"   /> 
                        </DataTemplate> 
                    </syncfusion:GridTemplateColumn.CellTemplate> 
                    <syncfusion:GridTemplateColumn.EditTemplate> 
                        <DataTemplate> 
                            <TextBox Text="{Binding EmployeeSalary, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"  /> 
                        </DataTemplate> 
                    </syncfusion:GridTemplateColumn.EditTemplate> 
                </syncfusion:GridTemplateColumn> 
               
 

Regards,

Sowndaiyan
 
 



DD Deanna Delapasse July 22, 2016 11:23 AM UTC

I need to do this from the code behind.  I see an UpdateTrigger property, but I can't find any kind of "PropertyChanged" enum.  How can it be set from the code?


            GridTextColumn gtc = new GridTextColumn()
            {
                HeaderText = "MyColumn",
                MappingName = "InspectionItem",       
                UpdateTrigger= ???
                CellTemplate = dt,
                SetCellBoundValue = true
            };
            sfdatagrid.Columns.Add(gtc);


DD Deanna Delapasse July 22, 2016 11:58 AM UTC

Found it I think.  Is this correct?   

UpdateTrigger = Windows.UI.Xaml.Data.UpdateSourceTrigger.PropertyChanged,

I see that the sample with xaml works now, but my app (code) still does not.   I will research some more.  Are there any other properties I would need to set/unset from the code?  I have this:

                       GridTextColumn gtc = new GridTextColumn()
                        {
                            HeaderText = groupedItem.Name,
                            MappingName = groupedItem.Id + ".InspectionItem",
                            CellTemplate = getTemplateForType(groupedItem.DataType),
                            UpdateTrigger = Windows.UI.Xaml.Data.UpdateSourceTrigger.PropertyChanged,
                            SetCellBoundValue = true                            
                        };




DD Deanna Delapasse July 22, 2016 08:28 PM UTC

Wait!!!   I realized that I was adding the trigger in the wrong spot!  I moved it into my data template where the actual control is bound and now it works great.   


Thanks you so much!!!   Issue resolved.


SP Sowndaiyan Paulpandi Syncfusion Team July 26, 2016 08:45 AM UTC

Hi Deanna,

Thanks for the update.

Please let us know if you need further assistance. 
Regards, 
Sowndaiyan  


Loader.
Live Chat Icon For mobile
Up arrow icon