Loading data
1. More useful ways to set up form data:
Formpanel.getform (). Setvalues ([{id: ' FirstName ', Value: ' Joe '}]);
Where the ID value is the name attribute value of field in form, value is the one to be assigned
2. Assigning values by object:
Ext.define (' Request ', {extend: ' Ext.data.Model ', fields: [' FirstName ', ' LastName ', ' emailaddress ', ' telnumbercode ', ' Telnumber ', ' requestdetails ', ' RequestType ']}); var Requestmodel = ext.create (' Request ', requestData); Formpanel.getform (). Loadrecord (Requestmodel);
3. You can also load data from the server via the Load method:
Formpanel.getform (). Load ({URL: ' Requestdetails.json '});
Submit Form
The simplest way is to call submit, commit to the specified URL
var submitForm = function () {formpanel.getform (). Submit ({URL: ' Submit.url '});}; var formpanel = ext.create (' Ext.form.Panel ', {... buttons: [{text: ' Submit form ', Handler:submitform}],items: [...]});
You can also get the object from the form and invoke the Ajax post method to commit:
var record = Formpanel.getform (). Getrecord ();
Validating Forms
Verify with VType:
{xtype: ' TextField ', Fieldlabel: ' Email Address ', Name: ' EmailAddress ', labelalign: ' Top ', cls: ' Field-margin ', Columnwidth:0.6,<strong>vtype: ' Email ' </strong>}
ExtJS Learning Note 3: loading, submitting, and validating forms