Events on RadDataForm: Schema [JSON]

Franchesca

I'm wondering if someone can share an example about how to use click events for getting the values of the form that were created using RadDataForm Schema from a json file.

Also if someone can share an example of a json file using properties like 'required' or max and min range will be awesome, you must know that the example that was given on the documentation doesn't work.

Thank you in advance.

Todor

When you are editing a json object, you can take the result through dataform's getEditedObject method.

The sample of the schema setup is an excerpt from this example application and should be working. Let us know what issue you observe with it. The schema in the example application contains most of the properties you can setup including min and max range for the stepper editor and min and max range for the range validator. If the username property for example was required, its definition in the schema would look like this:

{

"name": "username",

"editor": "text",

"required": true

}

However, if you need to show somehow that a field is required, you will have to do this manually. For example, add a "username *" as a displayName to indicate to the user that the field is required.

Let us know if you need further assistance.

Regards,
Todor
Telerik by Progress

Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items

Franchesca

Im trying to use the file named: "person_schema.json" that you provided to me.
{
"isReadOnly": false,

"commitMode": "immediate",

"validationMode": "immediate",

"properties":

[

{

"name": "name",

"displayName": "Your Name"

},

{

"name": "username",

"editor": "text"

},
{

"name": "password",

"editor": "password",

"validator": "MinimumLength",

"validatorParams": {

"length": 5,

"errorMessage": "Password must be at least 5 letters"

}

},

{

"name": "phone",

"editor": "phone"

},

{

"name": "age",

"displayName": "Your Age",

"editor": "stepper",

"editorParams":

{

"minimum": 18,

"maximum": 70

}

},

{

"name": "gender",

"displayName": "Your Gender",

"editor": "picker",

"valuesProvider": ["male", "female"]

},

{

"name": "grade",

"editor": "decimal"

},

{

"name": "email",

"editor": "email",

"validator": "MailValidator",

"displayName": "Your Email"

},

{

"name": "iq",

"editor": "slider",

"validator": "Range",

"validatorParams": {

"min": 60,

"max": 200,

"errorMessage": "IQ can't be less than 60 or more than 200"

}

},

{

"name": "city",

"editor": "segmentededitor",

"valuesProvider": ["New York", "Las Vegas", "Los Angeles"]

},

{

"name": "birthDate",

"editor": "datepicker"

}

]

}

I have no problems when I run something simple like:
{
"name": "username",
"editor": "text",
"required": true
}

But when I run the person_schema.json I got the following exception:

java.lang.Error:
DataFormTextEditor does not support properties of type JSONArray.
Please specify a value converter for your property.
at com.telerik.widget.dataform.visualization.core.EntityPropertyEditor.load(EntityPropertyEditor.java:157)
at com.telerik.widget.dataform.visualization.RadDataForm.load(RadDataForm.java:705)
at com.telerik.widget.dataform.visualization.RadDataForm.reload(RadDataForm.java:445)
at com.telerik.widget.dataform.visualization.RadDataForm.setEntity(RadDataForm.java:317)
at com.telerik.widget.dataform.visualization.RadDataForm.setEntity(RadDataForm.java:276)
at cr.co.sea.seaforms.Controller.Fragments.CustomFormFragment.onCreateView(CustomFormFragment.java:56)

Thank you in advance.

Todor

The mentioned example actually uses two json files:person_extended and person_schema. The first one is a representation of one object (a person with its name, age, etc) that will be edited with the data form. The second one is information that will be used by the data form to be property visualized (which editor to be used for editing password, how to validate the input, etc.).

The exception that you reported happens if you use the second file and try to edit is as an object with the data form as you do with the first file.

I hope this makes things more clear. If you are still having the issue, you can try to get the application from GitHub, try to run it and let us know if you are having issues wit it.

Regards,
Todor
Telerik by Progress

Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items

Franchesca

It was very helpful! I really appreciate your answerd. I could understand the example and it worked very good. I just had a problem while trying to test the field for birthday this field must show a datapicker but my apps stops when I try to select that field. The error said:

Todor

The BadTokenException when using Android Dialogs is a long time issue as you can see from this post from more than 5 years ago. The date picker in RadDataForm is a Dialog which uses the same context that you have passed to the data form's constructor. The solution is to use the activity that contains the form instead of the application context:

RadDataForm dataForm = new RadDataForm(this);

Assuming "this" is an activity. If you are inside a fragment, you can use the getActivity() method to get to the activity and pass it as a context for the data form.

I hope this helps. I wish you a great weekend.

Regards,
Todor
Telerik by Progress

Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items

This is again taken from the Schema sample, where the birthDate is the property edited with DataFormDateEditor, illustrating where to add the code for the editor date formatting.

I hope this information helps.

Regards,
Todor
Telerik by Progress

Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.