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
close icon

CustomRenderers and PasswordEditors do not update DataObject?

Hi,

after trying different things without any success, I decided to ask some experts ;-)

I want to use SfDataForm as a login form. I am using Xamarin Forms with Prism and Syncfusion.

Using the default form renderers, everything is fine: the values in the data object are all updated correctly in the view model and I am able to send the user inputs to my REST API.

At first, I faced some problems, when I tried to use a custom renderer for the form input fields (I wanted them to have a rounded border all around the field an wrote such a renderer in the Droid project. They are displayed correctly, but if I use the debugger and take a look into the data object, the values corresponding to the customized fields were not updated, they were all empty strings).
I downloaded one of your examples for custom renderers (http://www.syncfusion.com/downloads/support/directtrac/general/ze/Tab_DataForms1957976837.zip), added a button with a simple click event to take a look into the data object, but there is the same problem.

Then I tried to use a password editor for the password input. The value of this field is not transfered to the model/data object, either.

Can anyone help me please - where is my fault?

Thanks in advance :-)

(Please find attached the Tab_DataForms-sample with my adaptions...)

Attachment: DataFormTest_eba43cbc.zip

3 Replies

SG Swathi Gopal Syncfusion Team June 18, 2018 12:31 PM UTC

Hi Sven, 
  
Thank you for contacting Syncfusion support. 
  
We have checked the query with data form Item value not updated in underlying SfDataForm DataObject at run time on debugging and we are able to reproduce the issue. 
  
 In order to update the DataObject values when using custom editor, you should update the  DataForm Item editor value manually by using OnCommitValue method of DataFormEditor class which is used to commit the customized value in DataObject
  
Please refer the below code snippet 
  
public class CustomEditor : DataFormEditor<MyEntry>
    {
        public CustomEditor(SfDataForm dataForm) : base(dataForm)
        {

        }

        protected override void OnInitializeView(DataFormItem dataFormItem, MyEntry view)
        {
            view.Text = "Items";
        }
        protected override MyEntry OnCreateEditorView()
        {
            return new MyEntry();
        }

        protected override void OnWireEvents(MyEntry view)
        {
            view.TextChanged += View_TextChanged;
        }
    
        private void View_TextChanged(object sender, TextChangedEventArgs e)
        {
            OnCommitValue(sender as MyEntry);
        }

        protected override void OnCommitValue(MyEntry view)
        {
            var dataFormItemView = view.Parent as DataFormItemView;
            var textValue = view.Text;
            this.DataForm.ItemManager.SetValue(dataFormItemView.DataFormItem, view.Text);
        }
    }  
  
Please refer the below UG Link:  
  
The DataForm Item value of custom editor not updated from native renderer to Xamarin.Forms view so, TextChanged event of Xamarin.Forms Entry not fired, and value not committed in DataObject. We have already found and logged the issue with Xamarin.Forms view value not updated from native renderer to it and the fix will be available in our service pack release of Volume 2, 2018 release. We appreciate your patience until then.  
   
Regards, 
Swathi G 



CR Christina Reppel June 19, 2018 09:48 AM UTC

Thank you very much, this works fine for me!




JM Jeyasri M Syncfusion Team June 20, 2018 04:33 AM UTC

Hi Sven, 
 
We are glad to know that the given solution works for you. Please let us know if you need any further assistance.  
 
Regards,  
Jeyasri M  


Loader.
Live Chat Icon For mobile
Up arrow icon