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"); } }); |