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

Check if the record is Dirty (has been modified)

Hi, I created an event (GridGroupingControl1_CurrentRecordContextChange) where I need to check if the current record has been modified or not. After checking, I haven't found anything that will send the correct information during this event, more specifically, in the following action: CurrentRecordAction.LeaveRecordCalled - Thanks in advance! - Nicolas

10 Replies

AG Anish George Syncfusion Team July 7, 2016 09:53 AM UTC

Hi Nicolas, 

Thank you for using Syncfusion products. 

We request you to make use of the SourceListListChanged event for checking any record has been modified. In this event you can find whether an record is changed by using the ListChangedType property. Please refer the below code for reference. 

C#: 

this.gridGroupingControl1.SourceListListChanged += new TableListChangedEventHandler(gridGroupingControl1_SourceListListChanged); 

void gridGroupingControl1_SourceListListChanged(object sender, TableListChangedEventArgs e) 
{ 
    if (e.ListChangedType == ListChangedType.ItemChanged) 
    { 
        //Your code here 
        Trace.WriteLine(e.Table.CurrentRecord); 
    } 
} 


Please let us know if you need any further assistance. 

Regards 
Anish. 



NI Nicolas July 8, 2016 12:10 AM UTC

I tried the code and event, and everything works like a charm! Thank you Anish! - Nicolas


NI Nicolas July 8, 2016 12:32 AM UTC

I had one unexpected inconvenience, the SourceListListChanged is triggered on the load event, what condition should I add to exclude this event? - Nicolas


NI Nicolas July 8, 2016 02:01 AM UTC

I observe the same behavior when trying to navigate out to another form, I need to avoid triggering the SourceListListChanged as well - Thanks in advance - Nicolas


AG Anish George Syncfusion Team July 9, 2016 07:53 AM UTC

Hi Nicolas, 
 
Thank you for your update. 
 
We tried to replicate your scenario but we are unable to reproduce. The SourceListListChanged event will be called only when the data source is been changed. We tried to call this event in Load event but it is not getting fired at the beginning, it will be fired only when the current record is changed. Please refer the below sample in which we tested. Please try to replicate the issue in the below sample so that we can provide further details. 
 
 
Please let us know if we missed out anything. 
 
Regards, 
Anish 



NI Nicolas July 9, 2016 04:31 PM UTC

Hi, there are quite a few difference, let me share the major items: 

Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'SET ITEM COLLECTION IN COMBOBOX  - This Column - called "oFrequencyUnit" will show later very often (on each record change, even if the record is not dirty)
            Dim oSourceColl As New StringCollection
            oSourceColl.Add("")
            oSourceColl.Add("Days")
            oSourceColl.Add("Month")
            oSourceColl.Add("Year")
            GridGroupingControl1.TableDescriptor.Columns(8).Appearance.AnyRecordFieldCell.CellType = GridCellTypeName.ComboBox
            GridGroupingControl1.TableDescriptor.Columns(8).Appearance.AnyRecordFieldCell.ChoiceList = oSourceColl

GridGroupingControl1.Table.Records(0).SetCurrent() 'This triggers the CurrentRecordContextChange event
End sub

Private Sub GridGroupingControl1_CurrentRecordContextChange(sender As Object, e As CurrentRecordContextChangeEventArgs) Handles GridGroupingControl1.CurrentRecordContextChange
If (e.Action = Syncfusion.Grouping.CurrentRecordAction.EndEditCalled) Then '...
If (e.Action = Syncfusion.Grouping.CurrentRecordAction.EnterRecordComplete) Then '...
If e.Action = CurrentRecordAction.LeaveRecordCalled Then '...
If Not IsNothing(e.Table.CurrentRecord) Then '...
If e.Action = CurrentRecordAction.NavigateCalled Then '... 
If e.Action = CurrentRecordAction.BeginEditCalled Then '...
End sub

I have set a series of triggers to avoid unnecessary repetition of the code in SourceListListChanged (pretty heavy stuff), in the Form_Shown, NavigateCalled  and BeginEditCalled events, getting rid of the inconvenience during load time, and during form exit. That part is kinda resolved... Only remains the GridCombo ("oFrequencyUnit") which seems one of the causes of the problem - which as I said previously, is triggering the SourceListListChanged on a new record selection, and shows as "ItemChanged" even if the record is not dirty

Here is what I am using to date to filter the incoming in the SourceListListChanged  event

If Not IsNothing(e.PropertyDescriptor) Then
            Dim PDDN As String = e.PropertyDescriptor.DisplayName.ToString
            If (e.ListChangedType = ListChangedType.ItemChanged) AndAlso PDDN <> "oFrequencyUnit" AndAlso (GlobalVariables.EnterRecTrigger = 1) AndAlso (sender.TableControl.HasControlFocus = True) Then

I know it's not an easy one to replicate.... Thanks a bunch Anish and all the best - Nicolas


NI Nicolas July 9, 2016 08:48 PM UTC

Update - just to let you know, this "misbehavior" (SourceListListChanged kicking in the ItemChanged even if the table is not dirty) only happens in 1 form out of five. So I played the game of differences, and in other forms, in opposition with this one, when the event kicks in with ItemChanged, the e.PropertyDescriptor.Name has a "Nothing" value, while the Faulty form show a value of "oFrequencyUnit", which is the table field name. I tried to rule out this occurrence in the SourceListListChanged  but then it filters everything, and it is not kicking in as expected, Seeing this, I commented out my calls, removed the grid setup of combo based on a collection, changed the grid, changed the control, reset the values in the server. I think there is something happening that changes the property descriptor on the record change event, any idea to remove the behavior or other? Thanks in advance! - Nicolas 


AG Anish George Syncfusion Team July 11, 2016 12:17 PM UTC

Hi Nicolas,   

Thank you for your updates.   

We could see there are lot of changes to be done to replicate this issue. We request you to create a Direc-Trac incident regarding this so that our dedicated engineers will work on this and will give you a quick solution and for a better documentation. You can create Direc-Trac incidents in the below link.   
  
DT-link:   
  
Thanks for your patience. 

Regards,  
Anish. 



NI Nicolas July 11, 2016 07:44 PM UTC

Hi, finally... after some work on my side, I was able to circumvent this by the use of triggers. 

Basically, I had some changes made in RecordValueChanging event (by setting programmatically grid values) which was triggering the CurrentRecordContextChange event, and afterwards the SourceListListChanged event - as we cannot detect OldValues vs NewValues in the SourceSourceListChanged, I was pretty stucked there. Here is the solution I found:

In the Load event : set trigger to False as default value
In the RecordValueChanging event : Check if changes are made (e.NewValue vs e.Record.GetValue(fld)), if yes then set trigger to True, else False
In the SourceListListChanged event : check the trigger to run or not the sub, after, reset to False after it ran it

All the best and thank you for your continuing support! - Nicolas


VS Venkatesh Sundaram Syncfusion Team July 12, 2016 09:21 AM UTC

Hi Nicolas, 
 
Thanks for the update. Please let us know if you need any further assistance. 
Regards, 
Venkat. 


Loader.
Up arrow icon