ExtJS4 returns different URLs to the same formpanel.

Source: Internet
Author: User

Formpanel can be used as follows:

Var panel = Ext. create ('ext. form. panel ', {title: 'simple Form', bodyPadding: 5, width: 350, // will be submitted to this URL through AJAX requests // url: 'save-Form. php', // form field Fields will be vertically arranged, full width layout: 'anchor', ults: {anchor: '000000'}, // The fields ultulttype: 'textfield', items: [{fieldLabel: 'First name', Name: 'first', allowBlank: false}, {fieldLabel: 'Last name', name: 'last ', allowBlank: false}], // reset and save button. buttons: [{text: 'reset ', handler: function () {this. up ('form '). getForm (). reset () ;},{ text: 'save', formBind: true, // only enabled once the form is valid disabled: true, handler: function () {var form = this. up ('form '). getForm (); if (form. isValid () {form. submit ({success: function (form, action) {Ext. msg. alert ('saved successfully', action. result. msg) ;}, failure: function (form, action) {Ext. msg. alert ('Operation failed', action. result. msg) ;}}}}], renderTo: Ext. getBody ()});

Looking at the API, formpanel has no url configuration and does not obtain the api function .. It should be the parameter of the formpanel parent class ..

Later, I went to ext. form. basic and found the url configuration item ..

In Ext, FormPanel does not store form data. The data is saved by BasicForm. When submitting a form, you need to obtain the BasicForm in the current FormPanel for submission.

After obtaining the BasicForm object, you can submit the form.



Because two components need to be used in the project, the only difference between the two components is that the submitted url is different, so I didn't define the url when defining the component.


Then, when the component is added to different containers, different URLs are also given. The example above is used as an example.


Where needed

Panel. getForm (). url = '../LogSelectServlet'; // you can assign different URLs in different places.

This method is a good method for Component reuse ..



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.