Results 1 to 7 of 7

Thread: How to set defaults for every form in my application

  1. #1

    Default How to set defaults for every form in my application

    I find my self adding this to every form I make

    Is there a way to set these ONCE in one spot at the beginning of the script to save time/money/effort.

    Code:
                    , border: false                       
                    , labelPad: 10
                    , defaults: {
                        width: 180
                    }
                    , layoutConfig: {
                        labelSeparator: ''
                    }

  2. #2
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854

    Default

    You could just extend FormPanel and set those properties in the ctor.

  3. #3

    Default

    I thought about that but I was hoping that there was a way of just setting them through a prototype or even something like Ext.BLANK_IMAGE_URL so I wouldn't have to do an extend on every form I make.

    I just don't have the skill to work out how to do it yet

  4. #4
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854

    Default

    You don't have to extend every time you use - do it once and then instantiate that class instead of FormPanel. This is no different than the way Ext extends FormPanel from BaseForm and all the way up to Component.

    You could do this via the prototype, but you'd have to look at every one of the configs and see how they're used in the source. Simple ones can be added to the prototype, but some of the others may need different handling (e.g. defaults and layoutconfig)

    The 1st option is probably cleaner and once you understand the pattern, you can implement it wherever you need. I think there is also a tutorial on extending classes.

  5. #5

    Default

    actually it turns out i do have the skill

    This seems to do the job
    Code:
    Ext.form.FormPanel.prototype.border = false;

  6. #6

    Default

    Quote Originally Posted by tryanDLS View Post
    You don't have to extend every time you use - do it once and then instantiate that class instead of FormPanel. This is no different than the way Ext extends FormPanel from BaseForm and all the way up to Component.

    You could do this via the prototype, but you'd have to look at every one of the configs and see how they're used in the source. Simple ones can be added to the prototype, but some of the others may need different handling (e.g. defaults and layoutconfig)

    The 1st option is probably cleaner and once you understand the pattern, you can implement it wherever you need. I think there is also a tutorial on extending classes.
    Thanks, I do understand what you are saying but the prototype way suits me for now.

  7. #7
    Sencha User hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,966

    Default

    Have you tried it yet with all of 'em?

    Code:
    Ext.apply(Ext.form.FormPanel.prototype,
         
                    { border: false                       
                    , labelPad: 10
                    , defaults: {
                        width: 180
                    }
                    , layoutConfig: {
                        labelSeparator: ''
                    }
    });
    I'd be a little concerned about the possible layoutconfig and default clashes of the future (if this is going to effect all class instances)

    Cool way of dealing with it tho
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


Posting Permissions

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