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

DataFormItemManager crashing due to infinite loop

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.

1 Reply

SP Subburaj Pandian Veluchamy Syncfusion Team 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) 
                    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. 
Subburaj Pandian V  

Live Chat Icon For mobile
Up arrow icon