Mar 09, 2014, 9:23 PM
[CLOSED] Validate FormPanel and Save It using DirectMethods using MVC
Hi,
I have the piece of code below and I want to Save the form using Direct Methods and MVC but I try many samples and nothing seems to work. Could you help me? Please provide and MVC sample on how to save forms and validate it both on client and server side.
Another thing, can I update the Status bar from serve side instead of using Ext.Msg.Show() as I'm using in my controller? If yes, How can I do that.
Thank you very much
Here's the code:
I have the piece of code below and I want to Save the form using Direct Methods and MVC but I try many samples and nothing seems to work. Could you help me? Please provide and MVC sample on how to save forms and validate it both on client and server side.
Another thing, can I update the Status bar from serve side instead of using Ext.Msg.Show() as I'm using in my controller? If yes, How can I do that.
I notices that there are many examples using Web Forms and just a few using MVC. Even the examples page is much more complete for web forms than for MVC. Is there any good source of material for MVC Ext.NET aside from https://examples2.ext.net/ ?
Here's the code:
x.Panel()
.Title("Dados Paciente")
.AutoScroll(true)
.Border(false)
.Items(
x.FormPanel()
.ID("frmPaciente")
.Border(false)
.Layout(LayoutType.Fit)
.FieldDefaults(fd =>
{
fd.LabelAlign = LabelAlign.Left;
fd.MsgTarget = MessageTarget.Side;
fd.InvalidText = "Obrigat?rio";
fd.EnforceMaxLength = true;
fd.AutoFitErrors = true;
//fd.AllowBlank = false;
fd.SelectOnFocus = true;
fd.LabelWidth = 150;
})
.ItemsFromPartial("_DadosPaciente", Model.PacienteModel)
)
.Buttons(
x.Button()
.Icon(Icon.Erase)
.Text("Limpar Campos")
.OnClientClick("this.up('frmPaciente').getForm().reset();"),
x.Button()
.Icon(Icon.DatabaseSave)
.Text("Pr?ximo Passo")
.ID("btnSave")
.FormBind(true)
.Type(ButtonType.Submit)
.CausesValidation(true)
.DirectEvents(de =>
{
de.Click.Before = "return #{frmPaciente}.getForm().isValid();";
de.Click.Success = "#{DirectMethods}.SavePaciente()";
})
//.OnClientClick("return #{frmPaciente}.isValid();")
//.DirectClickAction("Save", "Paciente")
).Border(true),
Here's the controller code:[DirectMethod]
public ActionResult Save(PacienteModel paciente)
{
X.Msg.Show(new MessageBoxConfig
{
Message = "Salvando Paciente, aguarde...",
ProgressText = "Salvando...",
Width = 300,
Wait = true,
WaitConfig = new WaitConfig { Interval = 200 },
IconCls = "ext-mb-download",
AnimEl = this.GetCmp<Button>("btnSave").ClientID,
});
X.AddScript("setTimeout(function () { Ext.MessageBox.hide(); Sucesso('pnlDadosPessoais','Paciente salvo com sucesso!','Informa??o'); }, 4000);");
return this.Direct();
}
Last edited by Daniil; Mar 19, 2014 at 8:50 AM.
Reason: [CLOSED]