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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DataFormItemManager crashing due to infinite loop

Thread ID:

Created:

Updated:

Platform:

Replies:

146612 Aug 10,2019 01:41 PM UTC Aug 12,2019 10:37 AM UTC Xamarin.Forms 1
loading
Tags: SfDataForm
TJISMH
Asked On August 10, 2019 02:20 PM UTC

See attached example.

Trying to take advantage of DataFormItemManager SetValue override and the RefreshLayout method to referesh the layout when a specific value has been selected from a specific picker. 

AutoGeneratingDataFormItem is used to display/cancel controls based on the item selected.

The app is crashing at line 205 in SetValue method of FormItemManager class because the SetValue method is being continuously called.

Please advise as to how might accomplish this goal.

Attachment: formloop_e0626d4a.zip


PS: I also tried to avoid using RefreshLayout and instead relaunch the OnAppearing method through an event handler as an attempt to redisplay the form and in this case get the following exception: Non-static method requires a target in the GetValue method of FormItemManager.

Subburaj Pandian Veluchamy [Syncfusion]
Replied On August 12, 2019 10:37 AM UTC

Hi Bob, 
  
Thank you for contacting Syncfusion support. 
  
Based on the shared information, we have analyzed reported issue “DataForm crashes with custom DataFormItemManager class and RefreshLayout”. SetValue method ofDataFormItemManager class will be called twice in DataForm while validation andcommit value and since you are calling RefreshLayout inside SetValue method, Validation and Commit will trigger so SetValue called repeatedly. To overcome this DataForm RefreshLayout can be called only when needed, in your requirement call RefreshLayout only when DisplayMedicalPicker and DisplayNotes values are changed. 
  
Code Snippet: 
        
        public override void SetValue(DataFormItem dataFormItem, object value) 
         { 
                if (dataFormItem.Name == "ServiceType") 
                { 
                    DisplayMedicalPickerOldvalue = _vm.DisplayMedicalPicker; 
                    _vm.DisplayMedicalPicker = false; 
                    _vm.DisplayNote = false; 
                    if ((string)value == "Medical Expense") 
                    { 
                        _vm.DisplayNote = true; 
                        _vm.DisplayMedicalPicker = true; 
                    } 
                    base.SetValue(dataFormItem, value); 
                    if (DisplayMedicalPickerOldvalue != _vm.DisplayMedicalPicker) 
                        sfDataForm.RefreshLayout(true); 
                } 
                else 
                { 
                    base.SetValue(dataFormItem, value); 
                } 
          } 
  
We have modified your sample for the same, 
 
Sample link: formloop 
  
We hope this helps. Please let us know, if you would require any further assistance. 
 
Regards,
Subburaj Pandian V  


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon