Results 1 to 2 of 2

Thread: Problems extending of Ext.form.Panel - HELP

  1. #1
    Sencha Premium Member ebett's Avatar
    Join Date
    Nov 2010
    Location
    Argentina
    Posts
    31

    Default Problems extending of Ext.form.Panel - HELP

    Hi, i'm extending from Ext.form.Panel, when i invoke to setUpdateMode of my class, can't see any method or find with "down" of form items.
    Code:
    var form = Ext.create('Ats.AbmForm',{
                id: 'abm-form',
                idProperty: 'in_id',
                //contentEl:'form-inmo',
                addUrl: 'inmobiliaria.add',
                updateUrl: 'inmobiliaria.update',
                deleteUrl: 'inmobiliaria.remove',
                getUrl: 'inmobiliaria.get',
                items:[ ...    ]
            });
    
    
    form.setUpdateMode('ADD');
    This is my class:
    Code:
    Ext.define('Ats.AbmForm', {
        extend:'Ext.form.Panel',
        alias:'abmform',
        requires: ['Ats.Utils'],
        config: {
            idProperty:'id',
            addUrl:'',
            updateUrl:'',
            removeUrl:'',
            getUrl:''
        },    
        constructor:function(conf){            
            //this way is ok?
            this.initConfig(conf);
            this.initComponent(conf);
            this.callParent(arguments);                            
        },
        initComponent: function() {
            var me = this;
            this.updateMode=false;
            
            this.addEvents({
                    add: true,
                    update: true,
            remove: true,
                    cancel: true            
                    });
            
            Ext.apply(this, {
                frame: true,
                border:false,
                bodyBorder: true,
                bodyPadding: 10,
                style:{padding:'15 15 '},            
                width:500,
                layout: 'column',            
                fieldDefaults: {
                    labelAlign: 'left',
                    labelWidth: 90,
                    msgTarget: 'side',
                    invalidCls: ''            
                },
                buttonAlign:'center',
                buttons: [{
                    text: 'Guardar',
                    iconCls: 'icon-save',
                    itemId: 'save-btn',
                    id:'save-btn',
                    handler: function(){
                        var f = me.getForm();
                        if(f.isValid()){
                        //...
                        }
                      }
                    },{
                        iconCls:'icon-refresh',
                        text: 'Limpiar',
                        itemId: 'limpiar',
                        handler: function() {
                            me.getForm().reset();
                        }
                    },{
                        iconCls: 'icon-cancel',
                        text: 'Cancelar',
                        //itemId: 'cancel',
                        handler: function() {                        
                            me.fireEvent('cancel', me);
                        }
                    }
                ]            
            });
            //This is in sencha Class System examples but doesn't work  
           //Ats.AbmForm.superclass.initComponent.apply(this, arguments);        
        },
        clear: function(){
            this.getForm().reset();
        },
        setUpdateMode:function (mode){
            if (mode === 'ADD'){
                //this.down('#save-btn').enable(); //this doesnt work!
                this.buttons[0].setDisabled(false); //buttons[0] doesnt have any method!
                //this.down('#'+this.getIdProperty()).setReadOnly(false);
                this.items[0].setReadOnly(false);
                this.updateMode = false;
            }
            else if(mode === 'UPDATE'){
                //this.down('#save-btn').enable();
                this.buttons[0].setDisabled(false);
                //this.down('#'+this.getIdProperty()).setReadOnly(true);
                this.items[0].setReadOnly(true);
                this.updateMode=true;
            }        
            else if (mode === 'DETAIL'){
                //this.down('#save-btn').disable();
                this.buttons[0].setDisabled(true);
                
            }
        }    
    });

  2. #2
    Sencha Premium Member ebett's Avatar
    Join Date
    Nov 2010
    Location
    Argentina
    Posts
    31

    Default

    I forget put "this.callParent(arguments);" at the end of initComponent

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
  •