Results 1 to 8 of 8

Thread: Problem with variables

  1. #1

    Default Problem with variables

    Hi there,

    In my form i would use this.project_id

    PHP Code:
    WebApp.module.projects.formsWindow = function (config) {    

        if (!
    config) {
            
    config = {};
        }

        
    /* config */
        
    config.title 'Nieuw formulier'+this.project_id;
        
    config.width 500;
        
    config.height 300;
        
    config.xtype 'panel';
        
    config.layout 'fit';
        
    config.region 'center';
        
    config.border false;
        
    config.closeAction 'hide';

        
    /* items */
        
    config.items = [
            
    this.form = new Ext.form.FormPanel({
                
    xtype 'panel',
                
    border false,
                
    layout 'fit',
                
    region 'center',
                
    labelWidth 100,

                
    forceLayout true,

                
    defaults    : {
                    
    anchor '100%',
                },

                
    bodyStyle 'background-color: transparent;',

                
    items : [{
                    
    header false,
                    
    border true,
                    
    layout 'border',

                    
    items : [{
                        
    header false,
                        
    border false,
                        
    region 'north',
                        
    height 180,
                    },{
                        
    header false,
                        
    border false,
                        
    region 'center',
                        
    height 180,
                        
    html 'hahaha'+config.project_id+this.form_id
                    
    }]
                }]
            })
        ];
        
        
    /* constructor */
        
    WebApp.module.projects.formsWindow.superclass.constructor.call(thisconfig);\

    Ext.extend(WebApp.module.projects.formsWindowWebApp.windows,{
        
    initComponent : function(){
            
    WebApp.module.projects.formsWindow.superclass.initComponent.call(this);    
        },
        
        
    /* getParams */
        
    getParams : function () {
            if (
    this.project_id 0) {
                return {
    id this.project_id};
            }
        },
        
        
    /* setId */
        
    setId : function (id) {
            
    this.project_id id;
        },
        
        
    /* getId */
        
    getId : function () {
            return 
    this.project_id;
        },
        
        
    loadForm : function (project_idform_id) {
            
    this.form.getForm().load({
                
    url '/project/getform',
                
    method 'GET',
                
    params : {
                    
    project project_id,
                    
    form form_id
                
    },
                
                
    success : function () {
                    
    this.project_id project_id;
                    
    this.form_id form_id;
                    
                    
    /**
                    * constructor
                    */
                    
    WebApp.module.projects.formsWindow.superclass.show.call(this);
                },
                
                
    scope this
            
    });
            
            
    WebApp.module.projects.formsWindow.superclass.show.call(this);
        },

        
    addForm : function () {    
            
    WebApp.module.projects.formsWindow.superclass.show.call(this);
        }
    });
    }; 
    But i get undefined, does anyone know how i can use this variable?

    On this section it goes wrong :

    html : 'hahaha'+config.project_id+this.form_id

  2. #2
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    when exactly do you set the project_id?? do you do it when calling the constructor to instantiate a new instance of this class or with setId?

  3. #3

    Default

    I am calling the loadForm from my grid listener :

    formWindow = new WebApp.module.projects.formsWindow();
    formWindow.loadForm(record.data.project_id, record.data.id);

  4. #4
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    I can't tell what you're doing. you have some seriously weird logic :

    For instance: WebApp.module.projects.formsWindow.superclass.show.call(this); will get called no matter what in this block.

    Code:
      loadForm : function (project_id, form_id) {
            this.form.getForm().load({
                url : '/project/getform',
                method : 'GET',
                params : {
                    project : project_id,
                    form : form_id
                },
                
                success : function () {
                    this.project_id = project_id;
                    this.form_id = form_id;
                    
                    /**
                    * constructor
                    */
                    WebApp.module.projects.formsWindow.superclass.show.call(this);
                },
                
                scope : this
            });
            
            WebApp.module.projects.formsWindow.superclass.show.call(this);
        },

  5. #5

    Default

    Can you tell what is the right way?
    I want to open a new window from my grid listener where i can access the project_id and from_id,
    becaus i need them to get data from a json store.

  6. #6
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    the best way:

    grid fires event,
    causes an ajax request to fire,
    if successful, render window and form panel, passing the data from the resulting ajax request.

    You can't load a form panel if it's not rendered.

  7. #7

    Default

    Can you give me a short example?

  8. #8
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    Unfortunately not. I am currently working on helping a lot other forum members.

    Btw, i covered this type of workflow in my book.

    You can look at the code via http://app.extjsinaction.com or http://app.extjsinaction.com/app.zip

Similar Threads

  1. Replies: 2
    Last Post: 8 Jun 2009, 5:11 AM
  2. Small crazy problem with variables!!
    By casbar in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 8 Apr 2009, 7:48 AM
  3. about class name and variables
    By mirror in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 23 Dec 2008, 12:22 AM
  4. Getting variables from the server?
    By michiel in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 12 Nov 2007, 8:17 AM
  5. Extending variables
    By vironitronox in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 2 Nov 2007, 4:28 PM

Posting Permissions

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