limpiar formulario
olaa ando realizando un proyecto y aprendiendo atravez de esta gran pagina mi duda es como puedo realizar que cuando el formulario sea guardado
cierre la ventana o limpie el formulario.
tengo el siguiente codigo
Ext.ns('com.quizzpot.tutorial');
Ext.BLANK_IMAGE_URL = '../ext-3.0.0/resources/images/default/s.gif';
com.quizzpot.tutorial.SubmitFormTutorial = {
init: function(){
this.form = new Ext.form.FormPanel({
//standardSubmit: true, // traditional submit
url: 'submitform.php',
border:false,
labelWidth: 80,
defaults: {
xtype:'textfield',
width: 150
},
items:[
{
xtype:'numberfield',
fieldLabel:'codigo categoria',
name:'idcategoria',
allowBlank:false
},
{
xtype:'spacer',//esto me da espacio entre lineas
width: 250,
height: 15
},
{
fieldLabel:'Nombre Categoria',
name:'nombre_categoria',
allowBlank:false
},
{
xtype:'spacer',//esto me da espacio entre lineas
width: 250,
height: 5
},
{
xtype:'textarea',
fieldLabel:'Descripcion',
name:'descripcion',
allowBlank:false
}
]
});
this.win = new Ext.Window({
id:'mywin',
title: 'Submit data to the Server',
bodyStyle: 'padding:10px;background-color:#fff;',
width:300,
height:270,
items:[this.form],
buttons: [{text:'Save',handler:this.sendData,scope:this},{text:'Cancel',handler:this.limpiar,scope:this}]
});
this.win.show();
},
limpiar: function(){
this.form.getForm().reset()
},
sendData: function(){
//submit the form
var mask = new Ext.LoadMask(Ext.get('mywin'), {msg:'Guardando, un momento...'});
mask.show();
this.form.getForm().submit({
method: 'put',
params: {
extraParam: 'Extra params!',
param2: 'Param 2'
},
success: function(form,action){
mask.hide();
Ext.Msg.alert('success',action.result.msg);
},
failure: function(form,action){
mask.hide();
switch (action.failureType) {
case Ext.form.Action.CLIENT_INVALID:
Ext.Msg.alert('Failure', 'Form fields may not be submitted with invalid values');
break;
case Ext.form.Action.CONNECT_FAILURE:
Ext.Msg.alert('Failure', 'Ajax communication failed');
break;
case Ext.form.Action.SERVER_INVALID:
Ext.Msg.alert('Failure', action.result.msg);
break;
default:
Ext.Msg.alert('Failure',action.result.msg);
}
}
});
}
}
Ext.onReady(com.quizzpot.tutorial.SubmitFormTutorial.init,com.quizzpot.tutorial.SubmitFormTutorial);
¿Conoces a alguien que pueda responder esta pregunta? Comparte el link en Twitter o Facebook
Es necesario registrarse para poder participar en el foro! Si ya tienes una cuenta puedes entrar y comentar en este foro.
