Results 1 to 3 of 3

Thread: How to Change class prototype (ie, global defaults for form elements)?

  1. #1
    Sencha User
    Join Date
    May 2011
    Location
    Atlanta, GA
    Posts
    9

    Default How to Change class prototype (ie, global defaults for form elements)?

    Change class prototype properties/config (ie, global defaults for form elements)?

    I would like to change the following config options globally for my app:
    1. maxLength - defaults to Number.MAX_VALUE (infinity) ... I would like to set it to say maybe 100.
    2. validationEvent: defaults to 'keyup'.... I would like to set it to 'blur'
    3. validationDelay: defaults to 250. I might want to set this to something like 1500 if I dont change the validationEvent.

    Limitations:
    1. I do not want to change the EXTJS library of code... I would rather do this with Ext.extend or something in my application in order to modify the properties of the superclass (eg Ext.form.TextField).
    2. I do not want to add maxLength, validationEvent, and valiadationDelay to all of the form fields in my app. I want to do it in one place and have all the associated fields inherit from the modification of the class.

    If you know how to do this please advise with the code you used.

    Thx for your help,

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Answers
    585

    Default

    Are you using ExtJS 3 or 4? In ExtJS 4 the method Ext.extend() has largely been replaced with Ext.define() and Ext.form.TextField is now Ext.form.field.Text. If you're using ExtJS 3 then this isn't really the right forum.

    Either way, have you tried this?

    Code:
    Ext.override(Ext.form.field.Text, {
        maxLength: 100,
        validationDelay: 1500,
        validationEvent: 'blur'
    });
    I haven't tried it with these specific properties but as a general approach this usually works. A word of caution though, changing defaults globally like this can be a little risky if other classes rely on the original defaults.

  3. #3
    Sencha Premium Member
    Join Date
    Sep 2009
    Posts
    11

    Default validationDelay OBE

    It should also be noted that validationDelay did not carry over to ExtJS 4.x.
    I don't know what config item replaces it.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •