Summary of some common problems in the use of Sencha ExtJS

Source: Internet
Author: User

Recently has been using Sencha for front-end development, a separate post for the collation of common problems. The land will continue to add some content, colleagues also hope to be able to help everyone.

ExtJS submit submission causes Emptytext to submit into the form:

The code is as follows Copy Code

Win.form.submit ({
Submitemptytext:false,
URL: ' xxxxx ',
Method: ' Post '
});


ExtJS limits the maximum number of characters in text.

The code is as follows Copy Code

{
Fieldlabel: ' Education certificate number ',
Name: "Teacher.educationcardno",
Emptytext: ' Please enter the Education Certificate number ',
Enforcemaxlength:true,//The key is this.
Maxlength:18,
Value: ""
}


ExtJS Ajax to submit session expiration problem.

1. The header information of the session timeout is returned first through the back end, and then the Response.getresponseheader is used to determine whether there is such information to decide whether the session is invalid, the code is as follows:

The code is as follows Copy Code
Ext.onready (function () {
The processing of the request timeout begins
Ext.Ajax.on (' Requestcomplete ', checkusersessionstatus, this);
function Checkusersessionstatus (conn, response, options) {
var sessionstatus = Response.getresponseheader ("Sessionstatus");
if (typeof (Sessionstatus)!= "undefined") {
Ext.Msg.alert (' Prompt ', ' session timeout, please login again! ')
function (btn, text) {
if (btn = = ' OK ') {
var redirect = Root_path;
window.location = REDIRECT;
}
});
}
};

...... The problem of submitting the Ajax failed.

Ext.Ajax.request submission and submit in Ext.Form.panel are Ajax submissions, but the former determines that the return is not determined by the server-side {Success:false ...}, but through the returned responsetext The return value of the From, the commit in from, can be judged by the failure function. The code is as follows:

Ajax return failed:

The code is as follows Copy Code

Ext.Ajax.request ({
Url:url,
timeout:6000,
Success:function (response) {
var result = Ext.decode (Response.responsetext);
if (result.success) {
Ext.Msg.alert ("Prompt", "Data deletion succeeded");
} else {
Ext.Msg.alert ("hint", result.message);
}
Parentstore.reload ();
},
Error:function (response) {
Ext.Msg.alert ("Hint", "sorry, operation failed.") ");
Parentstore.reload ();
}
});

Form form Submission failed:

  code is as follows copy code

ext.getcmp ( "Wx_student_add"). Submit ({
    submitemptytext:false,
    clientvalidation: True,
    Url:this.url,
    method: ' Post ',
    success: function (form, action) {
        top. Ext.Msg.alert ("Hint", "save Success");
        ext.getcmp ("Tw_addstudent"). Destroy ();
        student_store.reload ();
   },
    failure:function (form, action) {
         Ext.Msg.alert ("Hint", "data submission failed");
        throw new Error ("Failed to save user data, please check server side return");
   }
});

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.