ExtJS4 how to give the same formpanel a different Url_extjs

Source: Internet
Author: User
Formpanel can be used in this way, an example on the API:
Copy Code code as follows:

var panel=ext.create (' Ext.form.Panel ', {
Title: ' Simple Form ',
Bodypadding:5,
WIDTH:350,

will be submitted to this URL via an AJAX request
URL: ' save-form.php ',

form field Fields will be arranged vertically, filling the entire width
Layout: ' Anchor ',
Defaults: {
Anchor: ' 100% '
},

The fields
DefaultType: ' TextField ',
Items: [{
Fieldlabel: ' Name ',
Name: ' I ',
Allowblank:false
},{
Fieldlabel: ' Last Name ',
Name: ' Last ',
Allowblank:false
}],

Reset and Save buttons.
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 (' Save Success ', action.result.msg);
},
Failure:function (form, action) {
Ext.Msg.alert (' Operation failure ', action.result.msg);
}
});
}
}
}],
RenderTo:Ext.getBody ()
);

Then look at the Api,formpanel has no URL configuration, nor get the API function. Think of it as a parameter to the parent class of Formpanel ...

Later went to look at the Ext.form.basic, there is a URL configuration items.

The Formpanel in ext does not save the form data, where the data is saved by Basicform, and when submitting the form you need to get the basicform in the current Formpanel to commit.

Form submission can be done after getting the Basicform object

Because there are 2 components to be used in the project, the only difference between the 2 components is that the URL is not the same, so I don't define the URL when I define the component

You can then also give the different URLs to the components when they are added to the different containers, and take the example above

where it's needed.
Copy Code code as follows:

Panel.getform (). Url= '. /logselectservlet ';//in different places you can assign different URLs like this

This approach is a good way to reuse components.

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.