SyncfusionExamples / save-or-cancel-dataform-data-xamarin

This repository contains a sample on How to save or cancel the edited data in the Syncfusion Xamarin.Forms Dataform (SfDataform)?

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to save or cancel the edited DataForm data in Xamarin.Forms (SfDataForm) ?

You can save or cancel the DataObject in Xamarin.Forms SfDataForm by storing the dataobject.

You can refer the following article.

https://www.syncfusion.com/kb/11312/how-to-save-or-cancel-the-edited-dataform-data-in-xamarin-forms-sfdataform

C#

Raise the property change event to store the DataObject.

private void DataForm_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
    if(e.PropertyName == "DataObject")
    formModel = dataForm.DataObject as DataFormModel;
}

C#

Cancel will reset the DataObject with stored dataobject.

private void OnCancel(object sender, EventArgs e)
{
    dataForm.DataObject = formModel;
    foreach (var property in dataForm.DataObject.GetType().GetProperties())
    {
        dataForm.UpdateEditor(property.Name);
    }
}

C#

Saves the edited data by using Commit method.

private void OnSaved(object sender, EventArgs e)
{
    dataForm.Validate();
    dataForm.Commit();
    formModel = dataForm.DataObject as DataFormModel;
}

About

This repository contains a sample on How to save or cancel the edited data in the Syncfusion Xamarin.Forms Dataform (SfDataform)?


Languages

Language:C# 100.0%