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.
Unfortunately, activation email could not send to your email. Please try again.

Check if the record is Dirty (has been modified)

Thread ID:

Created:

Updated:

Platform:

Replies:

124896 Jul 6,2016 11:31 PM Jul 12,2016 05:21 AM Windows Forms 10
loading
Tags: GridGroupingControl
Nicolas
Asked On July 6, 2016 11:31 PM

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

Anish George [Syncfusion]
Replied On July 7, 2016 05:53 AM

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. 


Nicolas
Replied On July 7, 2016 08:10 PM

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

Nicolas
Replied On July 7, 2016 08:32 PM

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

Nicolas
Replied On July 7, 2016 10:01 PM

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

Anish George [Syncfusion]
Replied On July 9, 2016 03:53 AM

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 


Nicolas
Replied On July 9, 2016 12:31 PM

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

Nicolas
Replied On July 9, 2016 04:48 PM

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 

Anish George [Syncfusion]
Replied On July 11, 2016 08:17 AM

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. 


Nicolas
Replied On July 11, 2016 03:44 PM

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

Venkatesh Sundaram [Syncfusion]
Replied On July 12, 2016 05:21 AM

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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;