PDA

View Full Version : Problems extending of Ext.form.Panel - HELP



ebett
9 Mar 2012, 5:22 AM
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.


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:


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);

}
}
});

ebett
9 Mar 2012, 6:53 AM
I forget put this at the end of "initComponent"
this.callParent(arguments);
:)