After ext is input, a check mark is displayed.

Source: Internet
Author: User

After using extjs for a while, I feel that ext has a lot of room for improvement in style and user experience. For example, displaying a check mark after a form is verified is a popular method. After two days of source code research, I finally found a simple implementation method. As follows:

I have done two things here:
1. When an error message is displayed in 'side' mode, the form is indented. I removed this effect.
2. switch between the check mark and the exclamation mark icon

Note:
I have customized the CSS style of the check mark, which is called 'icon-Yes'

// When the form verification is passed, the check box is displayed. // ext is rewritten. layout. component. field. field, which is used to process the label and error information of the form. // showvalidicon: booleanext. layout. component. field. field. override ({geterrorstrategy: function () {var me = This, owner = me. owner, strategies = me. errorstrategies, msgtarget = owner. msgtarget; var strategy =! Owner. preventmark & Ext. isstring (msgtarget )? (Strategies [msgtarget] | strategies. elementid): strategies. none; // customize showvalidicon: Boolean configuration item for the form // If showvalidicon is set to true and 'day' is used, use a check box (otherwise, it is the default, does not affect the original code.) If (msgtarget = 'day' & owner. showvalidicon) {// If (owner. isiconinit) {owner. errorel. setdisplayed (false); Owner. isiconinit = true;} // once verified, the icon owner is displayed. on ('validitychange', function (Me, valid) {me. errorel. setdisplayed (true );}); Ext. apply (strategy, {// unindent effect adjusthorizinsets: ext. emptyfn, layouthoriz: function (ownercontext, owner, size) {ownercontext. errorcontext. setprop ('x', size. width) ;}, layoutvert: function (ownercontext, owner) {ownercontext. errorcontext. setprop ('y', ownercontext. insets. top) ;}, prepare: function (ownercontext, owner) {var errorel = owner. errorel; errorel. addcls (ext. basecssprefix + 'form-inva Lid-Icon '); errorel. set ({'data-errorqtip ': Owner. getactiveerror () | ''}); var activeerror = owner. getactiveerror (), haserror = !! Activeerror; // switch the check icon errorel [haserror? 'Removecls': 'addcls'] ('icon-Yes'); Ext. layout. component. field. field. inittip () ;}}) ;}return strategy ;}});

   You only need to configure showvalidicon: true for multiple form items.

I am not satisfied with this code because the 'validitychange' event is used. If you define your own validitychange event, there may be sequence problems during execution. However, I am also helpless. The layout encapsulation of extjs4 is too complicated to figure out how it is implemented. Currently, no problem is found.

If you have better implementation methods, we are looking forward to sharing them !!!

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.