PDA

View Full Version : Hide form



OtavioF
26 Oct 2012, 9:52 AM
How can i hide a form as default and only make it appear when I click in a button?

code:

//Cria Formulário
formulario = Ext.widget('form',{
xtype: 'form',
id: 'form',

items: [{
xtype: 'textfield',
labelWidth : 110,
fieldLabel: 'Nome',
name: 'nome',
id: 'nome',
allowBlank: false
},{
xtype: 'textfield',
name: 'acao',
id: 'acao',
value: 'salvar',
hidden: true
},{
xtype: 'textfield',
name: 'ano',
id: 'ano',
value: '',
hidden: true
}]
});


//content com os 2 grids e formulario
var content = Ext.create('Ext.Panel', {
layout: 'vbox',
renderTo: 'metas',
autoScroll: true,
bodyPadding: 5,
items: [
formulario,
grid,
grid2
],
dockedItems: [{
xtype: 'toolbar',
items: [{
icon: '../source/images/add.png',
text: 'Novo',
scope: this,
handler: function(){


Ext.getCmp('form').getEl().show();


}
}, {
icon: '../source/images/delete.png',
text: 'Excluir',
disabled: true,
itemId: 'excluir',
scope: this,
handler: function(){

Ext.MessageBox.confirm('Confirmação', 'Deseja mesmo deletar esse registro?',
function(btn){
if(btn=='yes'){
var records = grid.getSelectionModel().getSelection();
var id = records[0].getData().idano;
jQuery.ajax({
type: "POST",
dataType: 'json',
url: "../comercial/metas",
data: {
acao: 'excluir',
ano: id
},
beforeSend: function(){
},
success: function(d){

store_ano.load();


},
error: function(){
Ext.Msg.alert('Erro', 'Erro ao excluir o registro');
}
});
}
});
}
}]
}],



});

Ext.EventManager.onWindowResize(function() {
content.setSize(undefined, undefined);
content.setHeight(Ext.getBody().getViewSize().height);
});

slemmon
26 Oct 2012, 3:42 PM
In the form config do
hidden: true

then on your button handler do
formulario.show()

OtavioF
29 Oct 2012, 2:32 AM
it's worked, ty slemmon. :)