Using The Commit Events

Developers can listen for commit operations either globally (for every editor) or locally (for a single editor). While listening for commit events, developers can cancel commit operations.

To listen for global commits RadDataForm exposes two methods. These are addCommitListener() and removeCommitListener(). The methods accept a single argument of type EntityPropertyCommitListener.

Here is a sample implementation of the interface:

public class CommitListener : Java.Lang.Object, IEntityPropertyCommitListener
{
    public void OnAfterCommit (IEntityProperty p0)
    {

    }

    public bool OnBeforeCommit (IEntityProperty p0)
    {
        // Return true to cancel the commit for the given property.
        if (p0.Name ().Equals ("Age")) {
            return true;
        }

        return false;
    }
}

Then to use listener simply add it to the data form commit listeners:

dataForm.BeforeCommit += (object sender, Com.Telerik.Widget.Dataform.Engine.BeforeCommitEventArgs e) => {
    e.Handled = true;
};

dataForm.AfterCommit += (object sender, Com.Telerik.Widget.Dataform.Engine.AfterCommitEventArgs e) => {
};

To listen for changes of a single property this code can be used:

CommitListener commitListener = new CommitListener ();
dataForm.GetExistingEditorForProperty ("Age").Property().AddCommitListener(commitListener);