加载数据
1.比较好用的设置form数据的方法:
formPanel.getForm().setValues([{id: 'FirstName', value: 'Joe'}]);
2.通过对象赋值:
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);
formPanel.getForm().load({ url: 'requestDetails.json' });
提交表单
最简单的办法就是调用submit,提交到指定url
var submitForm = function(){ formPanel.getForm().submit({ url: 'submit.url' }); }; var formPanel = Ext.create('Ext.form.Panel', { ... buttons: [{ text: 'Submit Form', handler: submitForm }], items: [ ... ] });
var record = formPanel.getForm().getRecord();
通过vtype验证:
{ xtype: 'textfield', fieldLabel: 'Email Address', name: 'EmailAddress', labelAlign: 'top', cls: 'field-margin', columnWidth: 0.6, <strong>vtype: 'email'</strong> }
原文地址:http://blog.csdn.net/litdwg/article/details/37995015