ExtJS Study Notes 3: Loading, submitting, and verifying forms

Source: Internet
Author: User

ExtJS Study Notes 3: Loading, submitting, and verifying forms

Load data

1. Easy-to-use method for setting form data:

formPanel.getForm().setValues([{id: 'FirstName', value: 'Joe'}]);

The id value is the name attribute value of field in form, and the value is the value to be assigned.

2. assign values through objects:

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 by using the load method:

formPanel.getForm().load({url: 'requestDetails.json'});


Submit Form

The simplest way is to call submit and submit it 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 obtain an object from form and call ajax post to submit the object:

var record = formPanel.getForm().getRecord();

Verification Form


Verify by vtype:

{xtype: 'textfield',fieldLabel: 'Email Address',name: 'EmailAddress',labelAlign: 'top',cls: 'field-margin',columnWidth: 0.6,vtype: 'email'}


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.