ExtJS Learning Note 3: loading, submitting, and validating forms

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.