Skip to content

Commit a889454

Browse files
committed
Added sdk samples for the data form commit modes.
1 parent 3aaa16c commit a889454

4 files changed

Lines changed: 70 additions & 38 deletions

File tree

.gitignore

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1 @@
1-
# built application files
2-
*.apk
3-
*.ap_
4-
5-
# files for the dex VM
6-
*.dex
7-
8-
# Java class files
9-
*.class
10-
11-
# generated files
12-
bin/
13-
gen/
14-
15-
# Local configuration file (sdk path, etc)
16-
local.properties
17-
18-
# Eclipse project files
19-
.classpath
20-
.project
21-
22-
# Proguard folder generated by Eclipse
23-
proguard/
24-
25-
# .gradle folder generated by Gradle
26-
.gradle/
27-
28-
# Intellij project files
29-
*.iml
30-
*.ipr
31-
*.iws
32-
.idea/
33-
/.idea
34-
35-
#Eclipse project files
36-
Chart/src/main/project.properties
37-
QSF/src/main/project.properties
38-
/.metadata
1+
.DS_Store

Samples-Java/Samples/src/main/java/activities/DataFormExamples.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public LinkedHashMap<String, ArrayList<ExampleFragment>> examples() {
3030
result.add(new DataFormJsonEditFragment());
3131
result.add(new DataFormSchemaSetupFragment());
3232

33+
result.add(new DataFormCommitEventsFragment());
34+
3335
dataFormExamples.put("Features", result);
3436

3537
return dataFormExamples;
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package fragments.dataform;
2+
3+
import android.os.Bundle;
4+
import android.support.annotation.Nullable;
5+
import android.support.v4.app.Fragment;
6+
import android.view.LayoutInflater;
7+
import android.view.View;
8+
import android.view.ViewGroup;
9+
10+
import com.telerik.android.sdk.R;
11+
import com.telerik.widget.dataform.engine.EntityProperty;
12+
import com.telerik.widget.dataform.engine.EntityPropertyCommitListener;
13+
import com.telerik.widget.dataform.visualization.RadDataForm;
14+
15+
import activities.ExampleFragment;
16+
17+
public class DataFormCommitEventsFragment extends Fragment implements ExampleFragment, EntityPropertyCommitListener {
18+
19+
@Override
20+
public String title() {
21+
return "Commit Events";
22+
}
23+
24+
@Nullable
25+
@Override
26+
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
27+
ViewGroup rootLayout = (ViewGroup)inflater.inflate(R.layout.fragment_dataform_commit, null);
28+
29+
RadDataForm form = (RadDataForm) rootLayout.findViewById(R.id.data_form_commit);
30+
31+
form.setEntity(new Person());
32+
33+
// The commit listener will be notified before and after each property is committed.
34+
// The global data form commit listeners are only notified when the CommitMode is set to Manual.
35+
form.addCommitListener(this);
36+
37+
// Add a commit listener for a specific property. This way the listener will be notified whenever a
38+
// commit is attempted regardless of the data form commit mode.
39+
form.getExistingEditorForProperty("Age").property().addCommitListener(this);
40+
41+
return rootLayout;
42+
}
43+
44+
@Override
45+
public boolean onBeforeCommit(EntityProperty entityProperty) {
46+
// To cancel the commit for a given property return true.
47+
if(entityProperty.name().equals("Age")) {
48+
return true;
49+
}
50+
51+
return false;
52+
}
53+
54+
@Override
55+
public void onAfterCommit(EntityProperty entityProperty) {
56+
// Do something after a property has been committed.
57+
}
58+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent" android:layout_height="match_parent">
4+
5+
<com.telerik.widget.dataform.visualization.RadDataForm
6+
android:id="@+id/data_form_commit"
7+
android:layout_width="match_parent"
8+
android:layout_height="match_parent"/>
9+
</FrameLayout>

0 commit comments

Comments
 (0)