1. #1
    Ext JS Premium Member
    Join Date
    Aug 2011
    Posts
    25
    Vote Rating
    1
    robert.peszek is on a distinguished road

      0  

    Default Recommended way to configure form.Basic from form.Panel in Ext 4 with Ext.define

    Recommended way to configure form.Basic from form.Panel in Ext 4 with Ext.define


    form.Basic has several important configuration parameters. These options are passed using initConfig() from form.Panel to form.Basic.

    So the following works and trackResetOnLoad will be configured on the form.Basic:

    Code:
    var formPanel1 = Ext.create('Ext.form.FormPanel', {
    trackResetOnLoad : true, //works! 
    . . .
    });
    What is the recommended way to do that using Ext.define?
    Code:
    Ext.define(‘myForm’, {
    extend: 'Ext.form.FormPanel',
    //config: {
    // trackResetOnLoad : true 
    //},  //-does not work
    //trackResetOnLoad : true, //-does not work
    . . .
    });
    Obviously, I could extend initComponent() and code something like:
    Code:
    initComponent: function() {
    this.callParent(arguments);
    this.getForm().trackResetOnLoad = true;
    }
    I just find this ugly.

    Am I missing something obvious?
    Thanks!
    Robert

  2. #2
    Sencha User
    Join Date
    May 2007
    Posts
    64
    Vote Rating
    0
    Specks is on a distinguished road

      0  

    Default


    Yep.

    Note**: If subclassing FormPanel, any configuration options for the BasicForm must be applied to the initialConfig property of the FormPanel. Applying BasicForm configuration settings to this will not* affect the BasicForm's configuration.
    Code:
    Ext.define('MyForm', {
        extend : 'Ext.form.Panel',
        initialConfig : {
            trackResetOnLoad : true
        },
        // ...
    });
    Last edited by Specks; 17 Aug 2011 at 8:53 AM. Reason: just giving an example
    The best advice I've been given ... Read the code.

  3. #3
    Ext JS Premium Member
    Join Date
    Aug 2011
    Posts
    25
    Vote Rating
    1
    robert.peszek is on a distinguished road

      0  

    Default


    Weird, this it fails my testcase using 4.0.2:

    Code:
     describe("Configuring form.Basic using FormPanel", function() {
      it("Should allow to configure form.Basic trackResetOnLoad property via form.Panel", function() {
       var formPanel1 = Ext.create('Ext.form.FormPanel', {
        trackResetOnLoad : true,        
           items: [
         {
             xtype: 'textfield',
             name: 'something'     
         }
        ]
       });
       
       Ext.define('exttests.ConfigTestFormPanel', {
           extend: 'Ext.form.FormPanel',
           //trackResetOnLoad : true, //this would not work
           //config: {     //this would not work
        //    trackResetOnLoad : true         
           //},
           initialConfig: {     
            trackResetOnLoad : true         
           },
              items: [
         {
             xtype: 'textfield',
             name: 'something'     
         }
        ]
       });
       var formPanel2 = Ext.create('exttests.ConfigTestFormPanel'); 
       
       expect(formPanel1.getForm().trackResetOnLoad).toBeTruthy(); //works 
       expect(formPanel2).toBeDefined();
       expect(formPanel2.getForm().trackResetOnLoad).toBeTruthy(); //fails
       
       this.after(function(){
        formPanel1.destroy();
        formPanel2.destroy();
       });
      });
     });

  4. #4
    Touch Premium Member
    Join Date
    Aug 2011
    Posts
    1
    Vote Rating
    0
    JoshHensley is on a distinguished road

      0  

    Default


    Robert, did you ever get this figured out? I am attempting to do exactly the same thing. I need to set trackResetOnLoad in the definition of my Ext.form.Panel subclass and cannot get it to work.

  5. #5
    Ext JS Premium Member
    Join Date
    Aug 2011
    Posts
    25
    Vote Rating
    1
    robert.peszek is on a distinguished road

      0  

    Default


    Josh:
    Simply set trackResetOnLoad on the form:

    myFormComponent.getForm().trackResetOnLoad=true;
    For example, you can do it by extending Ext.form.Panel initComponent():

    Code:
        
    initComponent: function() {
         this.callParent(arguments);
         this.getForm().trackResetOnLoad = true;
        },
    I think this is not elegant, so ... I asked the question.
    Robert

Thread Participants: 2

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar