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

Commit via Button

Thread ID:

Created:

Updated:

Platform:

Replies:

150495 Jan 9,2020 05:37 AM UTC Jan 9,2020 07:16 AM UTC Xamarin.Forms 3
loading
Tags: SfDataForm
Emad Afaq
Asked On January 9, 2020 05:37 AM UTC

How do i access the values from the individual fields when a button action is performed and validation is done? I want to pass those values to a rest service. what will be the best approach?

        private void OnCommit(object dataForm)
        {
            var dataFormLayout = dataForm as Syncfusion.XForms.DataForm.SfDataForm;
            var isValid = dataFormLayout.Validate();
            dataFormLayout.Commit();
            if (!isValid)
            {
                App.Current.MainPage.DisplayAlert("Alert", "Please enter valid details", "Ok");
                return;
            }

            App.Current.MainPage.DisplayAlert("Alert", "Money Transferred", "Ok");  // Here I want to perform the API Call. 
            dataFormLayout.IsReadOnly = true;
            this.IsVisible = false;
        }

Karthikraja Arumugam [Syncfusion]
Replied On January 9, 2020 06:49 AM UTC

Hi Emad, 
 
Thank you for contacting Syncfusion support. 
 
Based on the shared information we have checked your requirement of “Accessing field values after DataForm commit”. DataForm DataObject will hold the committed values of each field, you can get the entire class or individual field values from DataObject of DataForm. 
 
Please refer the following code example for the same, 
 
[C#] 
private void OnCommit(object dataForm) 
            var dataFormLayout = dataForm as Syncfusion.XForms.DataForm.SfDataForm; 
            var isValid = dataFormLayout.Validate(); 
            dataFormLayout.Commit(); 
 
            //Gets value of model class 
            var model = dataFormLayout.DataObject; 
 
            //Gets individual field values 
            var firstName = (dataFormLayout.DataObject as ContactsInfo).FirstName; 
            var lastName = (dataFormLayout.DataObject as ContactsInfo).LastName; 
            var email = (dataFormLayout.DataObject as ContactsInfo).Email; 
            var contactNumber = (dataFormLayout.DataObject as ContactsInfo).ContactNumber; 
 
 
We have prepared a sample based on your requirement, 
Link: DataForm 
 
We hope this helps. Please let us know if you would require any further assistance. 
 
Regards, 
Karthik Raja A 


Emad Afaq
Replied On January 9, 2020 07:12 AM UTC

Great!, I will give it a shot. Thanks Alot

Karthikraja Arumugam [Syncfusion]
Replied On January 9, 2020 07:16 AM UTC

Hi Emad, 
 
We are glad that the provided information helped you to achieve your requirements. Please get in touch with us if you would require further assistance. We are always happy to assist you. 
 
Regards, 
Karthik Raja A 


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